这是我的数据"*.txt“
ID LBI RTI WDI FLA PSF FSF ZDF1 PROZD
ar ?,35.30,2.60, ?,42.4,24.2,47.1,69
arn 1.23,27.00,3.59,122, 0.0,40.0,40.0,30
be 1.24,26.50,2.90,121,16.0,20.7,29.7,72
bi1 1.07,29.10,3.10,114,44.0, 2.6,26.3,68
bi2 1.08,43.70,2.40,105,32.6, 5.8,10.7,42
bie 1.39,29.50,2.78,126,14.0, 0.0,50.0,78
bn 1.31,26.30,2.10,119,15.7,15.7,30.4,72
bo 1.27,27.60,3.50,116,16.8,23.0,35.2,69
by 1.11,32.60,2.90,113,15.8,15.8,15.0,57然后,当我执行命令时,它失败了
r2 <- read.table('StoneFlakes.txt',header=TRUE,na.strings='?')错误;
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 1 did not have 9 elements有人能帮我吗?
发布于 2014-07-22 07:15:34
使用
text <- readLines('StoneFlakes.txt')
text <- gsub(",", " ", text)
read.table(textConnection(text), header=TRUE, na.strings='?')
#insted of using textConnection you can also use
read.table(text=text, header=TRUE, na.strings='?')https://stackoverflow.com/questions/24876240
复制相似问题