Return the configured data folder
jdata_dir.RdRead-side companion to joptions(data.dir = ...): returns the
currently configured data folder as a string, for use in scripts that need
the path itself (building a file path, checking existence, cleaning up test
files) without reaching into package-internal option names.
Value
A length-one character string (the configured folder, or
default); or default unchanged when it is NULL.
Details
joptions() prints the folder but returns invisible(NULL);
jdata_dir() returns it as a value. When no folder is configured, the
default is returned (".", the working directory, by default),
so the result drops straight into file.path. Pass
default = NULL to detect the unconfigured state explicitly.
Examples
if (FALSE) { # \dontrun{
joptions(data.dir = "Data")
jdata_dir() # "Data"
f <- file.path(jdata_dir(), "community.rds") # build a path in that folder
if (file.exists(f)) file.remove(f)
jdata_dir(default = NULL) # NULL if nothing configured
} # }