Last active
October 11, 2023 19:37
-
-
Save remlapmot/7a8d1dc9f7a3090d10653ad46dfb54ce to your computer and use it in GitHub Desktop.
Personal R settings file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rstan::rstan_options(auto_write = TRUE) | |
if (Sys.info()["sysname"] == "Windows"){ | |
# For improved execution time, we recommend calling | |
Sys.setenv(LOCAL_CPPFLAGS = '-march=corei7 -mtune=corei7') | |
} | |
# don't ask to save workspace on quit; `q()` | |
# utils::assignInNamespace( | |
# "q", | |
# function(save = "no", status = 0, runLast = TRUE) | |
# { | |
# .Internal(quit(save, status, runLast)) | |
# }, | |
# "base" | |
# ) | |
# speed up package installation | |
# as per https://www.jumpingrivers.com/blog/speeding-up-package-installation/ | |
if (requireNamespace("parallel", quietly = TRUE)) { | |
options(Ncpus = as.integer(ceiling(0.75*parallel::detectCores()))) | |
options(mc.cores = parallel::detectCores()) | |
} | |
# Use binary packages on Ubuntu 20.04 from RStudio Package Manager | |
# URL from https://packagemanager.rstudio.com/client/#/repos/1/overview | |
# Additionally make change in Rprofile.site file which is in ${R_HOME}/etc | |
# Find ${R_HOME} with R.home(component = "home") or Sys.getenv("R_HOME") | |
local({ | |
if (Sys.info()["sysname"] == "Linux") { | |
r <- getOption("repos") | |
# r["CRAN"] <- "https://packagemanager.rstudio.com/all/__linux__/focal/latest" | |
r["CRAN"] <- "https://packagemanager.posit.co/cran/__linux__/focal/latest" | |
options(repos = r) | |
} | |
# Running R in Terminal requires amending the HTTPUserAgent | |
# https://tshafer.com/blog/2023/07/posit-package-manager-linux | |
if (Sys.getenv('RSTUDIO') != 1L) { | |
options(HTTPUserAgent = sprintf( | |
"R/%s R (%s)", | |
getRversion(), | |
paste( | |
getRversion(), | |
R.version["platform"], | |
R.version["arch"], | |
R.version["os"] | |
) | |
)) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment