jamsession file paths
Usage
jamsession_paths(
sessions = NULL,
objects = NULL,
functions = NULL,
create = FALSE,
mode = "0755",
recursive = TRUE,
verbose = FALSE,
...
)Arguments
- sessions, objects, functions
charactervector with one or more file directory path locations, suitable for use bylist.files(path=x). When a value is defined, it is used to override the existingoptions()value, so the updated value will be used for all related jamsession functions. Note that any value""is removed, for examplesessions=""is equivalent tosessions=NULL.- create
logicaldefault FALSE, whether to create a file path that does not already exist. Only the first path is created for each of 'sessions', 'objects', 'functions' when none exist. The directory is created usingdir.create()using the argumentsmodeandrecursive.- mode, recursive
arguments passed to
dir.create()when necessary, by the argumentcreate.- verbose
logicalindicating whether to print verbose output.- ...
additional arguments are passed to
dir.create().
Details
This function retrieves the file path for each jamsession type:
'sessions': the folder where R sessions are saved, stored in
getOption("jam.sessions_path"), default"~/Projects/R-sessions".'objects': the folder where R objects are saved, stored in
getOption("jam.objects_path"), default"~/Projects/R-objects".'functions': the folder where R functions are saved, stored in
getOption("jam.functions_path"), default"~/Projects/R-scripts".
Each may have multiple paths, and may contain "." to include
the current working directory.
To use persistent values for your R environment, define
options() in the ~/.Rprofile in your HOME directory,
or in the folder of the active project.
To use custom file paths in each R session, use either ~/.Rprofile
or an appropriate method to define the relevant options.
options("jam.sessions_path"="/some/path/sessions"),options("jam.objects_path"="/some/path/objects"),options("jam.functions_path"="/some/path/functions").
Examples
## Display the current or default paths
c(jamsession_paths(functions=NULL))
#> $sessions
#> [1] "~/Projects/R-sessions"
#>
#> $objects
#> [1] "~/Projects/R-objects"
#>
#> $functions
#> [1] "~/Projects/R-scripts"
#>
## Update the functions path
jamsession_paths(functions="~/Projects/R-functions")
#> $sessions
#> [1] "~/Projects/R-sessions"
#>
#> $objects
#> [1] "~/Projects/R-objects"
#>
#> $functions
#> [1] "~/Projects/R-functions"
#>
## confirm the functions path has been updated
c(jamsession_paths())
#> $sessions
#> [1] "~/Projects/R-sessions"
#>
#> $objects
#> [1] "~/Projects/R-objects"
#>
#> $functions
#> [1] "~/Projects/R-functions"
#>
getOption("jam.functions_path")
#> [1] "~/Projects/R-functions"
## Revert the functions path
c(jamsession_paths(functions="~/Projects/R-scripts"))
#> $sessions
#> [1] "~/Projects/R-sessions"
#>
#> $objects
#> [1] "~/Projects/R-objects"
#>
#> $functions
#> [1] "~/Projects/R-scripts"
#>