我读了一个文本文件如下:
a <- read.table("~/Desktop/seed_ant.dat", header = TRUE, skip = 3)
但是未正确识别列:
> a
1 Colony,Distance,Mass,Headwidth,Headwidth (mm),Worker class
2 28,0,62.000,39.000,1.642,39-40
3 28,0,53.000,39.000,1.642,39-40
4 28,0,51.000,38.000,1.600,37-38
如何识别第1行中显示的列?
答案 0 :(得分:0)
尝试:
a <- read.csv("~/Desktop/seed_ant.dat", header = TRUE, skip = 3)
或
a <- read.table("~/Desktop/seed_ant.dat", header = TRUE, skip = 3, sep = ",")
根据data.frame
a
的输出,您可能需要使用skip = 4
来正确指示列。如果没有输入文件的前几行,很难说清楚。