config_file | R Documentation |
config_file
returns the absolute, normalized path to the configuration file of a program/package/app based on an optional app-specific commandline argument, an optional app-specific environment variable and the XDG Base Directory Specification
config_file(
app_name,
file_name,
cl_arg = commandArgs()[grep("--config-file", commandArgs()) + 1],
env_var = "",
sep = "/",
copy_dir = norm_path(xdg_config_home(), app_name),
fallback_path = NULL
)
app_name |
Name of the program/package/app |
file_name |
Name of the configuration file |
cl_arg |
Value of app specific commandline parameter |
env_var |
Value of app specific environment variable |
sep |
Path separator to be used on Windows |
copy_dir |
Path to directory where |
fallback_path |
Value to return as fallback (see details) |
The following algorithm is used to determine the location of $file_name
:
If $cl_arg
is a non-empty string, return it
Else, if $env_var
is a non-empty string, return it
Else, if $PWD/.config/$app_name
exists, return it
Else, if $XDG_CONFIG_HOME/$app_name/$file_name
exists, return it
Else, if $HOME/.config/$app_name/$file_name
exists, return it
Else, if $USERPROFILE/.config/$app_name/$file_name
exists, return it
Else, if $copy_dir
is non-empty string and $fallback_path
is a path
to an existing file, then try to copy $fallback_path
to
copy_dir
/$file_name
and return copy_dir
/$file_name
(Note, that
in case $copy_dir is a non-valid path, the function will throw an error.)
Else, return $fallback_path
Normalized path to the configuration file of $app_name
.
config_dir()
, xdg_config_home()
config_dir("myApp")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.