Skip to content

Instantly share code, notes, and snippets.

@IdoBar
Last active January 26, 2020 12:05
Show Gist options
  • Save IdoBar/222ab8c0d10481f793dc54f4dc857d0e to your computer and use it in GitHub Desktop.
Save IdoBar/222ab8c0d10481f793dc54f4dc857d0e to your computer and use it in GitHub Desktop.
Example of my .Rprofile
# If loading in an environment that doesn't respect my RPATH environment
# variable, set it here
sourceDir <- file.path(path.expand("~"), "R", "source")
if (Sys.getenv("RPATH") == "") {
if (!file.exists(sourceDir)) dir.create(sourceDir)
Sys.setenv(RPATH=sourceDir)
}
# Load commonly used functions and packages
# enable auto-completion of package names
utils::rc.settings(ipck=TRUE)
# Enable more than 100 packages loaded
if (getRversion() >= "3.4.0") Sys.setenv("R_MAX_NUM_DLLS"=300)
# Load custom functions from util.R file (see in https://gist.github.com/IdoBar/7f63547158ecdbacf31b54a58af0d1cc)
# if (interactive()){
# if (require(devtools) & curl::has_internet()) devtools::source_gist("7f63547158ecdbacf31b54a58af0d1cc", filename = "util.R")
# if (file.exists(search.path(utilsFileName))) source(search.path(utilsFileName))
# }
# Setup favourite CRAN mirror and a site install library.
# Choose CRAN mirror (1 will use https://cloud.r-project.org/ to Automatically redirect to servers worldwide through )
utils::chooseCRANmirror(ind = 1)
# fix "Warning: unable to access index for repository https://www.stats.ox.ac.uk/pub/RWin/src/contrib"
# https://stackoverflow.com/questions/45108484/warning-unable-to-access-index-for-repository-https-www-stats-ox-ac-uk-pub-rw#45112048
options(repos = getOption("repos")["CRAN"])
# options(repos=structure(c(CRAN="https://cloud.r-project.org/")))
# myLib <- "C:/Users/Public/R/MRO-3.3.1/library"
# .libPaths(c(myLib, .libPaths()))
# Function to run when R is started
.First <- function() cat(sprintf("\n\nDefault location to install new packages: '%s' \nCRAN mirror is set to: '%s'. \n\n Welcome to R!\n\n",
.libPaths()[1], getOption("repos")["CRAN"]))
@IdoBar
Copy link
Author

IdoBar commented Jan 26, 2020

Remove CRANExtra repository which causes warning (and leads to errors in the installation of some packages).
See this SO thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment