Install.packages() without data sets.

Is there a way to install packages in R without including sample data?

I can see that for R CMD INSTALL you can pass --no-data, but I can't seem to find a way to add this option to the install.packages() function.

My .proj file looks like

Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

I've tried to add

PackageInstallArgs: --no-multiarch --without-keep.source --no-data

without luck.

You can pass options for R CMD INSTALL with the INSTALL_opts argument:

## agridat has a bunch of datasets and no dependencies
install.packages("agridat", INSTALL_opts = "--no-data")
data(package = "agridat")
# no data sets found

Thanks alot - just the option I was looking for !

is it possible to set this on a project level? I have not been able to find the syntax if it exists.

I don't think there's a way to set an option in .Rproj files, but R does look for and run "profile" code when it starts a session. It will run any file named .Rprofile in the working directory on start-up. Run ?Startup for the documentation.

In the file, you can replace the function:

# .Rprofile
install.packages <- function(..., INSTALL_opts = NULL) {
  utils::install.packages(..., INSTALL_opts = c(INSTALL_opts, "--no-data"))

Note: R will look for and run an .Rprofile file in the working directory and then your home directory, but will stop once it finds one. So, if you have an .Rprofile file in both directories, only the one in the working directory will be run. So it might be a good idea to tack this onto the end of any project-specific .Rprofile script:

home_profile <- file.path(Sys.getenv("HOME"), ".Rprofile")
if (file.exists(home_profile)) {

Note 2: My success is spotty with providing the argument and replacing install.packages. The package always installs, but sometimes includes the datasets. I have no idea why.


Quite slick solution - thanks.

I think I am happy with the behaviour of it only using the .Rprofile in the current working directory, as I tend not to use a global .Rprofile. But for others the addon might just be perfect.

Seems to be sufficient to tackle the problem I am having, I will test it out.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.