tags:

views:

61

answers:

2

What is the difference between .tar.gz or .tgz files installed by R CMD install and install.packages()? I have made an example package with R CMD build, which I can currently install with R CMD install mypackage.tar.gz - and it works fine. I want to be able to install it through the install.packages() function (with a call like install.packages("mypackage.tar.gz",repos=NULL)). What additional steps do I need to take?

+2  A: 

I think the .tgz is the binary package on OS X, just like windows gets a binary .zip. Either one results from R CMD build.

So when you write "have made an example package with R CMD build, which I can currently install with R CMD install mypackage.tar.gz" you are inconsistent as the .tar.gz was the source and the result of the R CMD BUILD step. Start with the .tar.gz sources, make sure R CMD check and R CMD INSTALL work on them and then try R CMD binary.

Lastly, for install.packages() you need both the binary packages created by R CMD build --binary and a web-based repository containing file PACKAGES etc --- and as help(install.packages) says, see the R Installation and Administration manual for how to set up a repository.

Dirk Eddelbuettel
You can install a package from source (.tar.gz) from a local directory specifying repos=NULL. So you actually don't need to have a binary and a web repo. I just tested that it works on Ubuntu.
Matti Pastell
Ack -- never tried that but makes sense.
Dirk Eddelbuettel
Thanks - the distinction was that my tar.gz file was source rather than binary, as you suggested, and my getOption("pkgType") was binary.
Stephen
+2  A: 

It depends on your OS. On Linux you can install your .tar.gz package with the command you specify. If you are on Mac OS X, you need to specify that you are installing from source package and not binary (see ?install.packages on a Mac). As Dirk said the .tgz packages are binary builds for Mac and you can build them on a Mac.

If you want to build the package for Windows see http://win-builder.r-project.org/, which is a web service for building binary packages from source.

If you are planning to submit your package to CRAN, but wan't to test is first see Rforge

Matti Pastell
Thank you! the `type` argument on install.packages was what I was looking for! (since I'm on a Mac)
Stephen