jamsession file paths

jamsession_paths(
  sessions = NULL,
  objects = NULL,
  functions = NULL,
  create = FALSE,
  mode = "0755",
  recursive = TRUE,
  verbose = FALSE,
  ...
)

Arguments

sessions, objects, functions

character vector with one or more file directory path locations, suitable for use by list.files(path=x). When a value is defined, it is used to override the existing options() value, so the updated value will be used for all related jamsession functions. Note that any value "" is removed, for example sessions="" is equivalent to sessions=NULL.

create

logical indicating whether to create a file path that does not already exist. The directory is created using dir.create() using the arguments mode and recursive.

mode, recursive

arguments passed to dir.create() when necessary, by the argument create.

verbose

logical indicating whether to print verbose output.

...

additional arguments are passed to dir.create().

Value

list is returned, with named elements "sessions", "objects", and "functions".

Details

This function retrieves the file path for each jamsession type:

  1. "sessions" - the folder where R sessions are saved, this path is also stored in getOption("jam.sessions_path").

  2. "objects" - the folder where R objects are saved, this path is also stored in getOption("jam.objects_path").

  3. "functions" - the folder where R functions are saved, this path is also stored in getOption("jam.functions_path").

To use custom file paths in each R session, use either ~/.Rprofile or an appropriate method to define the relevant options:

When a file path is not defined in options(), the corresponding default path is used:

  • "sessions" uses default "~/Projects/R-sessions"

  • "objects" uses default "~/Projects/R-objects"

  • "functions" uses default "~/Projects/R-scripts"

(Note ~ refers to the home directory, which may also be defined by $HOME depending upon the computer operating system, for example linux, Mac OSX, or Microsoft Windows.)

See also

Other jamsession utilities: print_pkg_description()

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" #>