将数据帧指定为csv标头

时间:2016-09-23 12:37:38

标签: r csv

在R中,我想导入没有标题的CSV,但列(属性)名称保存在另一个数据框中。如何将带数据框的CSV作为标题导入?以下是示例,请参阅注释以获取更多详细信息

library('visNetwork') 
# nodes contain names of read.csv col which are col1 to col4    
id=c("col1", "col12", "col13", "col14") 
nodes=data.frame(id)
#data.csv doesnt have the header, I want to assign nodes as it header
links <- read.csv("data.csv", header=F)
# next command doesnt work properly, because r imported csv with defaults names(V1 to V4) which doesn't match names assigned in nodes
visNetwork(nodes, links, width="100%", height="400px", main="graph example")

0 个答案:

没有答案