Learn R Programming

envsetup (version 0.3.0)

rprofile: Function used to pass through code to the .Rprofile

Description

Function used to pass through code to the .Rprofile

Usage

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

Value

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

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

Examples

Run this code
# temp location to store configuration files
tmpdir <- tempdir()
print(tmpdir)

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

Run the code above in your browser using DataLab