Skip to contents

Function used to pass through code to the .Rprofile

Usage

rprofile(
  config,
  envir = getOption("envsetup.path.environment"),
  overwrite = TRUE
)

Arguments

config

configuration object from config::get()

envir

The environment to search for the path object. Defaults to the value of getOption("envsetup.path.environment").

overwrite

logical indicating if sourcing of autos should overwrite an object in global if it already exists

Value

Called for its side effects. Directory paths and autos are added to the search path based on your config.

Examples

# temp location to store configuration files
tmpdir <- tempdir()
print(tmpdir)
#> [1] "/tmp/RtmpQ1GZBD"

# Create an example config file
hierarchy <- "default:
  paths:
    data: !expr list(DEV = '/demo/DEV/username/project1/data',
                     PROD = '/demo/PROD/project1/data')
    output: !expr list(DEV = '/demo/DEV/username/project1/output',
                       PROD = '/demo/PROD/project1/output')
    programs: !expr list(DEV = '/demo/DEV/username/project1/programs',
                         PROD = '/demo/PROD/project1/programs')"

writeLines(hierarchy, file.path(tmpdir, "hierarchy.yml"))

rprofile(config::get(file = file.path(tmpdir, "hierarchy.yml")))
#> Assigned paths to