Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass configure arguments to install packages in R

I am trying to install a package in R from the CRAN repository. I have to pass a flag at the configure stage, but I can't figure out how to do it in install.packages:

> install.packages("Rmpfr")

..........
checking mpfr.h usability... no
checking mpfr.h presence... no
checking for mpfr.h... no
configure: error: Header file mpfr.h not found;
**maybe use --with-mpfr-include=INCLUDE_PATH**

(Note: I have MPFR installed in a custom location, since I am not root).

But how do I pass a specific flag with argument to the install.package command of R? .e.g " --with-mpfr-include=/path/to/mpfr/include "

based on the install.packages man page, I have tried:

install.packages("Rmpfr" , INSTALL_opts = "--with-mpfr-include=/path/to/mpfr/include")

install.packages("Rmpfr" , configure.args = "--with-mpfr-include=/path/to/mpfr/include")

install.packages("Rmpfr" , configure.vars = "--with-mpfr-include=/path/to/mpfr/include")

But none of them worked, with the same error.

like image 514
cmo Avatar asked May 17 '16 22:05

cmo


People also ask

How do I specify a library when installing a package in R?

R uses a single package library for each installed version of R on your machine. Fortunately it is easy to modify the path where R installs your packages. To do this, you simply call the function . libPaths() and specify the library location.

Which command is used to install packages R?

To install any package from CRAN, you use install. packages() . You only need to install packages the first time you use R (or after updating to a new version). **R Tip:** You can just type this into the command line of R to install each package.


1 Answers

I just stumbled upon this problem myself, trying to install udunits2 as a dependency of ggforce. This answer on the R devel mailing list worked in my case: I needed to pass a named character vector to configure.args keyed by the package name. This should would work for your case, then:

install.packages("Rmpfr",
  configure.args = c(Rmpfr = "--with-mpfr-include=/path/to/mpfr/include"))
like image 136
tomshafer Avatar answered Oct 11 '22 16:10

tomshafer