Site icon R-bloggers

Set package repositories at startup

[This article was first published on jottR, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The below code shows how to configure the ‘repos’ option in R such that install.packages() etc will locate the packages without having to explicitly specify the repository.  Just add it to the .Rprofile file in your home directory (iff missing, create it). For more details, see help(“Startup”).

local({
  repos <- getOption("repos");

  # http://cran.r-project.org/
  # For a list of CRAN mirrors, see getCRANmirrors().
  repos["CRAN"] <- "http://cran.stat.ucla.edu";

  # http://www.stats.ox.ac.uk/pub/RWin/ReadMe
  if (.Platform$OS.type == "windows") {
    repos["CRANextra"] <- "http://www.stats.ox.ac.uk/pub/RWin";
  }

  # http://r-forge.r-project.org/
  repos["R-Forge"] <- "http://R-Forge.R-project.org";

  # http://www.omegahat.org/
  repos["Omegahat"] <- "http://www.omegahat.org/R";

  options(repos=repos);
})

To leave a comment for the author, please follow the link and comment on their blog: jottR.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.