Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用以下命令将 .csv 文件导入 R:
mydata <- read.table("c:/data.csv", header=TRUE, sep=",", row.names="id")
但不断得到:
Error in data[[rowvar]] : attempt to select less than one element
.csv 文件如下所示:
Title1,Title2,Title3 1,2,3 4,5,6 7,8,9
任何帮助将非常感激!
mydata <- read.csv("c:/mydata.csv")
请改用 read.csv 函数。它会根据第一行中的值自动填充列标题。
row.names 参数应该是一个具有行数长度的向量。现在简单地省略这个论点可能会解决这个问题。该文档清楚地表明 row.names 是一个向量,尽管提出更多信息的异常会很好。