我正在尝试粘贴数据框的两列,然后使用“查看”功能查看生成的字符向量,但是我收到此错误:
“视图中出错:'名称'属性[2]的长度必须与向量[1]相同”
这是我可重复的例子:
name1 <- c("A2015169","A2015177","A2015185","A2015193","A2015201","A2015209","A2015217","A2015225",
"A2015233","A2015241","A2015249","A2000049","A2000057","A2000065","A2000073","A2000081",
"A2000089","A2000097","A2000105","A2000113","A2000121","A2000129","A2000137","A2000145",
"A2000153","A2000161","A2000169")
name2 <- c("h07v06","h07v06","h07v06","h07v06","h07v06","h07v06","h07v06","h07v06","h07v06","h07v06",
"h07v06","h08v06","h08v06","h08v06","h08v06","h08v06","h08v06","h08v06","h08v06","h08v06",
"h08v06","h08v06","h08v06","h08v06","h08v06","h08v06","h08v06")
df <- data.frame(name1,name2)
names <- paste(df$name1,df$name2,sep=".")
View(names)
答案 0 :(得分:1)
非常感谢你的建议。我使用RStudio版本0.99.485和R-3.2.2。弗兰克,我使用相同的R版本(3.2.2)没有RStudio,这次它工作。亲爱的獾獾,谢谢你的建议,我更改了变量“名称”的名称,仍然无法在RStudio 0.99.485中工作。 Alexey Ferapontov,我使用相同版本的R和RStudio 0.98.1103,这次它工作了!这说,似乎问题是RStudio版本。我相信这回答了这个问题,但我不想赞成这个问题,我认为Frank和Alexey Ferapontov应该得到它。
答案 1 :(得分:1)
我认为没有与R版本相关的问题。
您在代码中提到的结果是一种列表,我们无法使用View()
查看列表类型数据。
View()
仅用于数据框。
例如
x = letters
y = seq(1:26)
z = data.frame(x,y)
View(z)