我已经下载了SemiPar包,我一直在尝试使用命令数据(fuel.frame)附加数据集fuel.frame,但没有成功。我得到的错误是:
Error in read.table(zfile, header = TRUE, as.is = FALSE) :
more columns than column names
In addition: Warning messages:
1: In read.table(zfile, header = TRUE, as.is = FALSE) :
line 1 appears to contain embedded nulls
2: In read.table(zfile, header = TRUE, as.is = FALSE) :
line 5 appears to contain embedded nulls
3: In read.table(zfile, header = TRUE, as.is = FALSE) :
incomplete final line found by readTableHeader on 'C:/...
你可以告诉我这里有什么问题吗?我试图在网上寻找解决方案,但似乎这个包适用于除了我自己以外的所有人。
我的sessionInfo()
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SemiPar_1.0-4.1
loaded via a namespace (and not attached):
[1] cluster_1.15.3 grid_3.1.1 lattice_0.20-29 MASS_7.3-33 nlme_3.1-117
[6] tools_3.1.1
谢谢。
答案 0 :(得分:4)
" fuel.frame"文件实际位于库中的../SemiPar/data/目录中。您可以使用.libPaths()
功能。对我来说它返回:
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/3.1/Resources/library"
如果你看那里,你应该看到" fuel.frame.txt.gz"它告诉你它是一个扩展为文本文件的gzip文件(这是data()
调用在将其传递给read.table()
之前所做的事情)。它的顶部看起来像:
car.name Weight Disp. Mileage Fuel Type
"Eagle Summit 4" 2560 97 33 3.030303 Small
"Ford Escort 4" 2345 114 33 3.030303 Small
"Ford Festiva 4" 1845 81 37 2.702703 Small
"Honda Civic 4" 2260 91 32 3.125000 Small
"Mazda Protege 4" 2440 113 32 3.125000 Small
"Mercury Tracer 4" 2285 97 26 3.846154 Small
"Nissan Sentra 4" 2275 97 33 3.030303 Small
"Pontiac LeMans 4" 2350 98 28 3.571429 Small
正如您所看到的,我的副本的错误消息不正确。因此,您可能希望使用未命名的系统来扩展.gz文件并进行调查。 (我在OSX 10.7.5中运行的R 3.1.1(SnowLeopard版本)没有出错。)通过我的设置,这也成功了:
data('fuel.frame',
lib.loc='/Library/Frameworks/R.framework/Versions/3.1/Resources/library/')