样本数据
DATA FILE LINE 1 CONTAINS 6 VARIABLES
3-29 Arlanta hoozers 4 7 status
代码
> myfile <- read.fwf(
+ file = "events.dat",
+ width = c(4,10,8,2,2,8),
+ col.names = c("date", "city",
"nickname",
"won", "lost", "status"),
+ colClasses = c("character", "character",
"character", "numeric", "numeric",
"character"),
+ na.strings=".",
+ sep=" ",
+ strip.white = TRUE,
+ )
read.table(file = FILE, header = header, sep = sep, row.names = row.names, 中的错误:列名多于列名
这个错误信息告诉我什么?日期看起来很可疑。在读取数据之前,我无法使用 lubridate 包。
这里的建议?我很难决定对我的输入文件使用哪个读取命令。我应该让延期成为我的补偿吗?谢谢。毫米
根据我们在评论中的讨论,此解决方案对您有用:
read.delim(events.dat)
回答你的 f/u 问题sep="\t"
意味着分隔符是一个制表符。R 比将实际制表符插入引号更喜欢该命令。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句