Install.packages() without data sets.

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)) {
  source(home_profile)
}
rm(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.

2 Likes