[R] install.packages and package dependencies
@rii@mstei@ m@iii@g oii gm@ii@com
@rii@mstei@ m@iii@g oii gm@ii@com
Thu Feb 6 18:36:23 CET 2025
It appears that install.packages does not automatically install package
dependencies when the package is installed via a URL. As an example, here
is what I get when I attempt to install the latest ggplot2 tarball via its
URL on CRAN:
> install.packages("
https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz")
inferring 'repos = NULL' from 'pkgs'
trying URL 'https://cran.r-project.org/src/contrib/ggplot2_3.5.1.tar.gz'
Content type 'application/x-gzip' length 3604371 bytes (3.4 MB)
==================================================
downloaded 3.4 MB
ERROR: dependencies ‘cli’, ‘glue’, ‘gtable’, ‘isoband’, ‘lifecycle’,
‘rlang’, ‘scales’, ‘tibble’, ‘vctrs’, ‘withr’ are not available for package
‘ggplot2’
* removing
‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/ggplot2’
Warning in install.packages :
installation of package
‘/var/folders/m7/ztk511fj6vl4m6bw7vh47nk40000gn/T//RtmpmmFBOH/downloaded_packages/ggplot2_3.5.1.tar.gz’
had non-zero exit status
>
Is there a parameter I can give to install.packages so that it will
automatically install all the packages the package (in this example
ggplot2) needs? I've read the documentation of install.packages several
times, and am confused by the interplay of the various parameters. When I
type getOption('repos') I get:
CRAN
"https://cran.rstudio.com/"
attr(,"RStudio")
[1] TRUE
Without this it looks like installing from a URL is a 2-step process:
install.packages(c(<packages the package needs>))
install.packages("<url of package tarball>")
I am aware that there are some contributed packages (such as devtools and
remotes) that do this for you in a single line. But I am curious whether
this is possible via install.packages alone.
[[alternative HTML version deleted]]
More information about the R-help
mailing list