On Thu, 6 Feb 2025 09:36:23 -0800 arilamstein at gmail.com wrote:> It appears that install.packages does not automatically install > package dependencies when the package is installed via a URL. [...] > When I type getOption('repos') I get: > > CRAN > "https://cran.rstudio.com/" > attr(,"RStudio") > [1] TRUEDo you set this value somewhere (via an environment variable or start up file)? Or is it this value because you use RStudio as IDE? If you use RStudio, please be aware that RStudio has its own version of install.packages(): RStudio> install.packages function (...) .rs.callAs(name, hook, original, ...) <environment: 0x12a530f00> So if you are using RStudio, you will have to talk with Posit about changing the behaviour of install.packages(). If you want the behaviour of utils::install.packages() to change, I am sure that R-Core will consider any diff that implements the new/improved behaviour. :-) Cheers, Berwin
@rii@mstei@ m@iii@g oii gm@ii@com
2025-Feb-12 23:56 UTC
[R] install.packages and package dependencies
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]]
Maybe Matching Threads
- install.packages and package dependencies
- Best way to handle dependency on non-CRAN package / large data package?
- install.packages and package dependencies
- install.packages and package dependencies
- Best way to handle dependency on non-CRAN package / large data package?