Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to not need user input for install.packages(type = "both")

Normally, install.packages(..., type = "both") requires user input if there is a package that needs to be built from source.

For example (currently, with R 3.5.1), install.packages(c("feather", "tidyr"), type = "both")) will install tidyr from binary and feather from source, as long as there is a user to click "yes" when it gets to the feather install.

Is there a way to automatically click yes, or not require user input through some of the options to install.packages()?

Note: install.packages(..., type = "source") does not require user input, but it builds all packages, which is not the desirable behavior in this case.

like image 705
r_alanb Avatar asked Jul 25 '18 04:07

r_alanb


People also ask

How do you install a package and all of the other packages on which for Depends?

How to install for a package and all of the other packages on which for depends? Explanation: To install a package named for, open up R and type install. packages(“for”). To install foo and additionally install all of the other packages on which for depends, instead type install.

Do you have to install R packages every time?

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. Once a package is installed, you don't have to install it again while using the version of R!

How do I install multiple R packages at once?

You can install multiple packages by passing a vector of package names to the function, for example, install. packages(c("dplyr", "stringr")) . That function will install the requested packages, along with any of their non-optional dependencies.

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.


1 Answers

The install.packages.compile.from.source option can be set to "always" to install packages from source without prompting for UI. The default is "interactive", which will prompt for user confirmation when using type="both".

Solution:

options(install.packages.compile.from.source = "always")
install.packages(c("feather","tidyr"), type = "both")
like image 164
r_alanb Avatar answered Oct 09 '22 06:10

r_alanb