我在R中编写了一个非常基本的包.事实上,我按照本教程创建了一个基本包.
我的包在linux中运行得很好.例如:
> install.packages("linmod", repos=NULL)
Warning in install.packages("linmod", repos = NULL) :
argument 'lib' is missing: using '/home/jpgoel/R/i486-pc-linux-gnu-library/2.9'
* Installing *source* package ‘linmod’ ...
** R
** data
** preparing package for lazy loading
** help
*** installing help indices
>>> Building/Updating help pages for package 'linmod'
Formats: text html latex example
** building package indices ...
* DONE (linmod)
> library(linmod)
> data(mod1)
> mod1
Call:
linmod.default(x = x, y = y)
Coefficients:
Const Bwt
-0.3566624 4.0340627
现在,我拿了我的"linmod"文件夹,将其复制到Windows XP,并尝试了以下内容:
> install.packages("C:\\Documents\ and\ Settings\\foo\\Desktop\\linmod",repos=NULL)
Error in gzfile(file, "r") : cannot open the connection
In addition: Warning messages:
1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file
2: In gzfile(file, "r") :
cannot open compressed file 'linmod/DESCRIPTION', probable reason 'No such file or directory'
>
好的.然后我把那个文件夹放到.zip文件中.然后我去了Packages - >从本地zip文件安装包...并选择了我的包.
> utils:::menuInstallLocal() updating HTML package descriptions > library(linmod) Error in library(linmod) : 'linmod' is not a valid installed package
我很难过.我的包没有任何本机代码(例如,没有用C编写的扩展名)
随意从这里下载.zip (下载链接一直在底部,"将文件保存到您的PC")