你在用R讀取數(shù)據(jù)時,是否曾出現(xiàn)過這樣的錯誤
Warning messages:
1: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : EOF within quoted string
2: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : number of items read is not a multiple of the number of columns
場景:我在讀取一個兩列的數(shù)據(jù)(884行伞芹,第一行為行名),讀取命令為:
data<-read.table("data.txt",header = TRUE,sep = "\t",stringsAsFactors = FALSE)
code
data
出現(xiàn)了上方的Warning
堕仔,數(shù)據(jù)可以讀取卓研,但是讀取的并不完整盏檐,只剩下452行,讀入的這個數(shù)據(jù)明顯不符合我們的預(yù)期榜贴。
修正后的代碼:
data<-read.table("data.txt",header = TRUE,sep = "\t",stringsAsFactors = FALSE,quote = "")
在讀取命令中增加了一個參數(shù)quote = ""
,讀取完成豌研,data包含883行,符合預(yù)期唬党,可以使用鹃共。
掃描下方二維碼關(guān)注生信客部落公眾號:
生信客部落