I have a library (in this case ggplot2) installed at the system level. I want to install ggplot2 and all it's dependencies to a new directory which is specify in the R_LIBS_USER variable. When I run install.packages('ggplot2', dependencies=TRUE)
it seems to make a copy of ggplot2 directory but none of the other other dependencies. Is there any way to make sure that the other packages that ggplot2 depends on makes it to the directory that I specified in R_LIBS_USER?
Perhaps this ... under the assumption that your $R_LIBS_USER environment variable has been puahed to a second position in the search paths somehow by another location. (Check with .libPaths()
)
install.packages('ggplot2', lib= .libPaths[2], dependencies=TRUE)
Or:
install.packages('ggplot2', lib= Sys.getenv(("R_LIBS_USER"), dependencies=TRUE)
Comments suggest that the problem is that imported packages are already in libraries that R is searching... so won't be unnecessarily installed. There are no packages in the Depends entry for the DESCRIPTION
file, but there are packages named in the Imports
section. To read dependencies from an installed package:
packageDescription("ggplot2", fields = c("Depends","Imports") )
#-----------
Depends: R (>= 3.1)
Imports: digest, grid, gtable (>= 0.1.1), MASS, plyr (>=
1.7.1), reshape2, scales (>= 0.3.0), stats
-- File: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/ggplot2/Meta/package.rds
-- Fields read: Depends, Imports
> str( packageDescription("ggplot2", fields = c("Depends","Imports") ) )
List of 2
$ Depends: chr "R (>= 3.1)"
$ Imports: chr "digest, grid, gtable (>= 0.1.1), MASS, plyr (>= 1.7.1),\nreshape2, scales (>= 0.3.0), stats"
- attr(*, "class")= chr "packageDescription"
- attr(*, "fields")= chr [1:2] "Depends" "Imports"
- attr(*, "file")= chr "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/ggplot2/Meta/package.rds"
The downvote suggests that someone doesn't like having these facts pointed out but ... facts are facts.