tags:

views:

334

answers:

2

I have written a very basic package in R. In fact, I followed this tutorial for creating a basic package.

My package works just fine in linux. eg:

> 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:

> 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.

> 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.)

Feel free to download the .zip from here (the link to download is all the way at the bottom, "Save file to your PC")

+4  A: 

Consider using the excellent CRAN Win-Builder service to turn your R package sources into an installable zip file for Windows.

You simply upload by ftp, and shortly thereafter get notice about your package.

Dirk Eddelbuettel
Okay, so, I had assumed that if your R package doesn't have native code, then it ought to run on both windows/linux, since the code itself is cross-platform. Apparently this is not the case? And, is there some command-line utility which will convert between the two formats?
rascher
AFAICT "it used to work this way" and you still find old mailing posts recommending it. These days the internal format has changed and you seemingly cannot convert, hence the lack of a converter tool. So if you need it often, install the Windows toolchain (see e.g. Rob's tutorial) or else go with Win-Builder.
Dirk Eddelbuettel
+1  A: 

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.

Rob Hyndman