[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 13 00:56:25 CET 2025


Duncan and Berwin,

Thank you for your help.

I really wanted confirmation from someone more experienced than me that I
wasn't missing something. It looks like there is no way to do this in one
line in base R, and that's fine.

For reference, the packages that I am doing this for are acs and
choroplethr, both of which were archived today. (choroplethr depends on
acs, and acs was archived due to a NOTE. I was the maintainer of
chroplethr).

I believe that at least a few people will still want to use choroplethr, at
least for a little while. The instructions I have posted on this are
consistent with what I wrote above for:

# Install binary versions of acs' dependencies, then install acs from source
acs_imports = c("stringr", "XML", "plyr", "httr")
install.packages(acs_imports)
install.packages("
https://cran.r-project.org/src/contrib/Archive/acs/acs_2.1.4.tar.gz")

# Install binary versions of choroplethr's dependencies, then install
choroplethr from source
choroplethr_imports = c("Hmisc", "ggplot2", "dplyr", "R6", "WDI", "ggmap",
"RgoogleMaps", "tigris", "gridExtra", "xml2", "tidyr", "tidycensus",
"testthat", "choroplethrMaps", "choroplethrAdmin1")
install.packages(choroplethr_imports)
install.packages("
https://cran.r-project.org/src/contrib/Archive/choroplethr/choroplethr_3.7.3.tar.gz
")

I believe that both the remotes and devtools packages have functions that
can do this in one line of code. But I believe that they install all the
dependencies from source. I found that there were intermittent failures
with that (not in the acs or choroplethr packages, surprisingly). And also
it was substantially slower (319 seconds for devtools' install_version vs.
43 seconds for the code I showed above).

Berwin, your post actually made me chuckle. In the original draft of my
post I wrote something like "I tried to look at what install.packages does
by typing 'install.packages' but it shows me something I can't understand:

> install.packages
function (...)
.rs.callAs(name, hook, original, ...)
<environment: 0x118030cc0>"

I am indeed using RStudio and I had no idea that they overwrote that
function!

	[[alternative HTML version deleted]]



More information about the R-help mailing list