Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install R package from source, without changing PATH (Windows)

Tags:

windows

r

I'm trying to install package rpart for R-2.14.0 on Windows 7, but I get the warning:

package ‘rpart’ is not available (for R version 2.14.0)

So I download the tar.gz file from the package page. I have installed Rtools but I disabled all the options, including the one that changes the PATH. Then I do the following:

> install.packages("C:/rpart_3.1-50.tar.gz", type="source")
Installing package(s) into ‘C:/Users/backupSam/Documents/R/win-library/2.14’
(as ‘lib’ is unspecified)
inferring 'repos = NULL' from the file name
* installing *source* package 'rpart' ...
** libs

*** arch - i386
ERROR: compilation failed for package 'rpart'
* removing 'C:/Users/backupSam/Documents/R/win-library/2.14/rpart'
* restoring previous 'C:/Users/backupSam/Documents/R/win-library/2.14/rpart'
Warning messages:
1: running command 'C:/PROGRA~1/R/R-214~1.0/bin/i386/R CMD INSTALL -l "C:/Users/backupSam/Documents/R/win-library/2.14"   "C:/rpart_3.1-50.tar.gz"' had status 1 
2: In install.packages("C:/rpart_3.1-50.tar.gz", type = "source") :
  installation of package ‘C:/rpart_3.1-50.tar.gz’ had non-zero exit status

Any suggestions?

like image 661
screechOwl Avatar asked Feb 23 '23 11:02

screechOwl


1 Answers

Since you have to set the PATH, but you're hesitant to do so because you're afraid you may hose something up, you can do it temporarily in your R session via:

pathRtools <- paste(c("c:\\Rtools\\bin",
  "c:\\Rtools\\MinGW\\bin",
  "c:\\MiKTeX\\miktex\\bin",
  "c:\\R\\bin\\i386",
  "c:\\windows",
  "c:\\windows\\system32"), collapse=";")
Sys.setenv(PATH=paste(pathRtools,Sys.getenv("PATH"),sep=";"))
like image 120
Joshua Ulrich Avatar answered Feb 25 '23 12:02

Joshua Ulrich