Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert source code (mypackage.tar.gz) to window installation (mypackage.zip) in R

Is it possible to convert source code (mypackage.tar.gz) to window installation (mypackage.zip) in R at home ? How can I do it ?

I could unzip tar.gz using 7-Zip. When I tried to recompile the following is error message:

Loading required package: mypackage Failed with error: ‘‘mypackage’ is not a valid installed package’

like image 212
jon Avatar asked Dec 22 '22 00:12

jon


2 Answers

No, you need to install Rtools and compile the binary package ending in .zip from the source package ending in .tar.gz. And the package / building "compiling" step is needed even for packages containing only R code.

Try one of the many tutorials on the web about package building on Windows.

Alternatively, use the awesome win-builder site to create the package for you.

like image 114
Dirk Eddelbuettel Avatar answered Dec 24 '22 00:12

Dirk Eddelbuettel


I develop my R packages on Linux machines - if you do too, this is what I do and it may help you.

To make the .zip for R, I basically 'install' it to a temporary directory and zip it up. That .zip file can be used on windows.

# make the package:
R CMD build my_package

# make tmp directory
mkdir tmp

# install the package to temp directory
R CMD INSTALL -l tmp my_package.tar.gz

# zip it up
cd tmp
zip -r my_package.zip my_package

# move your zip file back out and delete tmp directory
mv my_package.zip ../
cd ../
rm -rf tmp

I put this all into a makefile for ease so that I can type (e.g.) make doc to generate documentation (since I use roxygen2), make package to do the R CMD build, make zip to convert the .tar.gz into a .zip etc.

like image 26
mathematical.coffee Avatar answered Dec 24 '22 00:12

mathematical.coffee