Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install an R package from the source tarball on windows?

Tags:

shell

r

The forecast package for R has been updated to version 2.12, but there are currently only windows binarys for 2.11 available on CRAN.

How do I install an R package from the source on Windows?

like image 337
Zach Avatar asked Jan 19 '11 19:01

Zach


People also ask

How do I manually install an R package?

Go into R, click on Packages (at the top of the R console), then click on "Install package(s) from local zip files", then find the zip file with arm from wherever you just saved it. Do the same thing to install each of the other packages you want to install.


3 Answers

I know this is an old question but it came up first in my Google search for this same question, even though I knew the answer I just wanted something to copy and paste. Which makes it worth improving the answer for future reference. So here is what works for me:

Install rtools, then:

install.packages(path_to_file, repos = NULL, type="source") 
like image 187
Peter Ellis Avatar answered Oct 13 '22 06:10

Peter Ellis


Start by reviewing the section on Windows packages in the R Installation and Administration manual, then carefully follow the instructions from The Windows toolset appendix.

I know it's usually bad form to mainly provide links in an answer, but these are links to the canonical references on this topic. I simply link to them rather than summarize their contents, since they should be accurate for the most current R release.

like image 44
Joshua Ulrich Avatar answered Oct 13 '22 06:10

Joshua Ulrich


Two answers that may help you avoid the hassle of installing Rtools.

  1. Use http://win-builder.r-project.org/ to build a binary version, download it, and install (using install.packages(...,repos=NULL))
  2. If the package has no binary component (i.e. no src directory with C, C++, or Fortran code that needs to be compiled during installation (not true for forecast, but possibly useful some other time) then simply specifying type="source" within the install.packages call (whether from a repository or a local copy of the source tarball (.tar.gz file)) will install the source package, even on Windows.
like image 33
Ben Bolker Avatar answered Oct 13 '22 08:10

Ben Bolker