I have to perform a remote R installation on an Ubuntu 16.10 system. As part of this, I have to install specific packages on that host. I want to install these packages Rcmdr
, list
, ggplot2
, afex
, lsmeans
. Since I am doing this remotely, I cannot use
sudo -i R
to first enter the R CLI and then install with install.packages()
. Instead I must somehow install the packages from the Ubuntu CLI.
I found these links:
However, some packages have dependencies:
list
package depends on utils
and sandwich
. Rcmdr
package depends on grDevices
, utils
, splines
, RcmdrMisc
, car
. ggplot2
package also has dependencies. I would like to install only the packages Rcmdr
, list
, ggplot2
with all their dependencies. Normally, I would do it this way:
install.packages(c('Rcmdr','list','ggplot2'), dependencies=TRUE)
QUESTIONS
How do I specify the dependencies option in R CMD
for one package only? Is this the way to install them
R CMD INSTALL -l Rcmdr dependencies=TRUE, list dependencies=TRUE, \\ ggplot2 dependencies=TRUE, afex, lsmeans
or this incorrect?
repos
parameter inside R CMD INSTALL -l
? EDIT
As per the first comment below, sudo
is not needed above.ie sudo -i R
can be replaced by R
.
Regarding your questions:
This may not be the best approach. Consider instead Rscript -e 'install.packages(...)'
which is what R CMD INSTALL ...
calls anyway. You have better control over options here. And read on...
On all Ubuntu machines at work and home I do this via /etc/R/Rprofile.site
via something like
## Example of Rprofile.site
local({
r <- getOption("repos")
r["CRAN"] <- "https://cloud.r-project.org"
r["ghrr"] <- "https://ghrr.github.io/drat"
options(repos = r)
})
where we usually add a third and network-local repo. You may just want CRAN here -- it uses the 'always-close to you' CDN administered by RStudio for the R Project and R Consortium. The ghrr drat is a helper repo I set up.
sudo
is not needed per something I add to the official Debian/Ubuntu package for R -- but you need to be a member of the group that owns /usr/local/lib/R/site-library
.
Now, if I may, two more suggestions:
The r
executable is available to you via sudo apt-get install r-cran-littler
. I use it on the command-line; and you probably want to look into the basic install.r
script and the extended install2.r
. I tend to create a softlink from /usr/local/bin
to the package directory for these and other (such as update.r
). I have been running many (Ubuntu and Debian) machines like that for many years.
We actually have about 3000 CRAN packages as binaries for Ubuntu so you could just do sudo apt-get install ...
and all dependendies would get resolved. Look eg in this script of mine (which uses them on Travis) or some of the Docker files I maintain such as this one .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.