我有一个这样的数据框(我知道结构有点乱,但我需要它,因为输入数据(Excel)有三个级别的列):
wait()
我想使用:
将第2行指定为列名 NA NA.1 NA.2 NA.3
1 United States of America United States of America United States of America United States of America
2 Alabama Arizona Arkansas California
3 <NA> <NA> <NA> <NA>
4 1225 399 1547 726
df <- structure(list(`258` = structure(c(3L, 2L, NA, 1L), .Label = c("1225",
"Alabama", "United States of America"), class = "factor"), `285` = structure(c(3L,
2L, NA, 1L), .Label = c("399", "Arizona", "United States of America"
), class = "factor"), `279` = structure(c(3L, 2L, NA, 1L), .Label = c("1547",
"Arkansas", "United States of America"), class = "factor"), `340` = structure(c(3L,
2L, NA, 1L), .Label = c("726", "California", "United States of America"
), class = "factor")), .Names = c("258", "285", "279", "340"), row.names = c(NA,
4L), class = "data.frame")
但是,我只获得等级而不是显示状态的角色。反过来也很容易。但是,我坚持了一段时间没有找到解决方案。有任何想法吗?感谢