tools::R_user_dir() of R (>= 4.0.0)
Closed this issue · 3 comments
HenrikBengtsson commented
R_user_dir <-
function(package, which = c("data", "config", "cache"))
{
stopifnot(is.character(package), length(package) == 1L)
which <- match.arg(which)
home <- normalizePath("~")
path <-
switch(which,
data = {
if(nzchar(p <- Sys.getenv("R_USER_DATA_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_DATA_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("APPDATA"), "R", "data")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Application Support",
"org.R-project.R")
else
file.path(home, ".local", "share")
},
config = {
if(nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_CONFIG_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("APPDATA"), "R", "config")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Preferences",
"org.R-project.R")
else
file.path(home, ".config")
},
cache = {
if(nzchar(p <- Sys.getenv("R_USER_CACHE_DIR")))
p
else if(nzchar(p <- Sys.getenv("XDG_CACHE_HOME")))
p
else if(.Platform$OS.type == "windows")
file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache")
else if(Sys.info()["sysname"] == "Darwin")
file.path(home, "Library", "Caches",
"org.R-project.R")
else
file.path(home, ".cache")
})
file.path(path, "R", package)
}
mllg commented
Will upload a new version by the end of this week.
HenrikBengtsson commented
Thxs, I see it just hits CRAN. A minor issue with NEWS entry: I think it should say:
"Added backport for R_user_dir for R versions prior to 3.6.0 4.0.0."
mllg commented
Oh, right. Fixed now in the master branch.