I have written a very basic package in R. In fact, I followed this tutorial for creating a basic package.
我已经在r中写了一个非常基本的包。
My package works just fine in linux. eg:
我的包在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
Now, I took my "linmod" folder, copied it to Windows XP, and tried the following:
现在,我把我的“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' >
Okay. So then I took that folder and placed it into a .zip file. Then I went to Packages -> Install package(s) from local zip files... and selected my package.
好吧。然后我把文件夹放到。zip文件中。然后我去包->安装包从本地zip文件…选择我的包。
> utils:::menuInstallLocal() updating HTML package descriptions > library(linmod) Error in library(linmod) : 'linmod' is not a valid installed package
I'm stumped. My package doesn't have any native code (eg, no extensions written in C.)
我难住了。我的包没有任何本地代码(例如,没有在c中编写的扩展)。
Feel free to download the .zip from here (the link to download is all the way at the bottom, "Save file to your PC")
可以从这里下载。zip(下载的链接在底部,“保存文件到你的电脑”)
3 个解决方案
#1
12
Consider using the excellent CRAN Win-Builder service to turn your R package sources into an installable zip file for Windows.
考虑使用优秀的CRAN Win-Builder服务将R包源代码转换为Windows的可安装zip文件。
You simply upload by ftp, and shortly thereafter get notice about your package.
您只需通过ftp上传,不久之后就会收到关于您的包的通知。
#2
8
You can't just zip up the directory from linux. You need to build specifically for Windows. I've put some instructions here. However, if you are developing on some other platform first, then Dirk's solution is simpler.
你不能仅仅从linux上压缩目录。您需要专门为Windows构建。我在这里写了一些说明。但是,如果您首先在其他平台上开发,那么Dirk的解决方案会更简单。
#3
0
If the package is rather simple, the following function works for me on Windows for a package "MY_PACKAGE_1.0.tar.gz" generated with R (OS: Ubuntu with the command R CMD build MY_PACKAGE
)
如果包相当简单,那么下面的函数适用于Windows上的“MY_PACKAGE_1.0.tar”包。用R(操作系统:Ubuntu和命令R CMD构建MY_PACKAGE)生成gz
install.packages("MY_PACKAGE_1.0.tar.gz", repos=NULL, type="source")
The option type="source"
is necessary, otherwise it does not work.
选项类型=“source”是必需的,否则它不能工作。
#1
12
Consider using the excellent CRAN Win-Builder service to turn your R package sources into an installable zip file for Windows.
考虑使用优秀的CRAN Win-Builder服务将R包源代码转换为Windows的可安装zip文件。
You simply upload by ftp, and shortly thereafter get notice about your package.
您只需通过ftp上传,不久之后就会收到关于您的包的通知。
#2
8
You can't just zip up the directory from linux. You need to build specifically for Windows. I've put some instructions here. However, if you are developing on some other platform first, then Dirk's solution is simpler.
你不能仅仅从linux上压缩目录。您需要专门为Windows构建。我在这里写了一些说明。但是,如果您首先在其他平台上开发,那么Dirk的解决方案会更简单。
#3
0
If the package is rather simple, the following function works for me on Windows for a package "MY_PACKAGE_1.0.tar.gz" generated with R (OS: Ubuntu with the command R CMD build MY_PACKAGE
)
如果包相当简单,那么下面的函数适用于Windows上的“MY_PACKAGE_1.0.tar”包。用R(操作系统:Ubuntu和命令R CMD构建MY_PACKAGE)生成gz
install.packages("MY_PACKAGE_1.0.tar.gz", repos=NULL, type="source")
The option type="source"
is necessary, otherwise it does not work.
选项类型=“source”是必需的,否则它不能工作。