我有一个我试图在R中读取的csv文件,由于某种原因,R认为第一行是每列的标题,这是不正确的。有没有办法解决这个问题。 这是我的命令:
test <- as.matrix(read.csv(file="filetable.csv", sep=",", header=FALSE))
我得到这样的东西
AATCAGGC X25070
[1,] "ACAAGGCT" " 50687"
[2,] "ACACGATC" " 47483"
[3,] "ACACTGAC" " 18339"
[4,] "ACAGGAGT" " 48550"
第一行应该是数据的一部分
在记事本中打开filetable.csv我得到了这个
AATCAGGC,25070
ACAAGGCT,50687
ACACGATC,47483
ACACTGAC,18339
ACAGGAGT,48550
由于
答案 0 :(得分:4)
它的标题= FALSE而不是标题:http://stat.ethz.ch/R-manual/R-patched/library/utils/html/read.table.html
> tempFile <- tempfile()
> writeLines(c("AATCAGGC,25070",
"ACAAGGCT,50687",
"ACACGATC,47483",
"ACACTGAC,18339",
"ACAGGAGT,48550"),tempFile,sep="\n")
> readLines(tempFile)
[1] "AATCAGGC,25070" "ACAAGGCT,50687" "ACACGATC,47483" "ACACTGAC,18339" "ACAGGAGT,48550"
> as.matrix(read.csv(tempFile,sep=",",header=FALSE))
V1 V2
[1,] "AATCAGGC" "25070"
[2,] "ACAAGGCT" "50687"
[3,] "ACACGATC" "47483"
[4,] "ACACTGAC" "18339"
[5,] "ACAGGAGT" "48550"