devtools (version 0.8)

with_something: Execute code in temporarily altered environment.

Description

  • in_dir: working directory
  • with_collate: collation order
  • with_env: environmental variables
  • with_libpaths: library paths
  • with_locale: any locale setting
  • with_options: options
  • with_path: PATH environment variable
  • with_par: graphics parameters

Usage

with_env(new, code)

with_locale(new, code)

with_collate(new, code)

in_dir(new, code)

with_libpaths(new, code)

with_options(new, code)

with_par(new, code)

with_path(new, code, add = TRUE)

Arguments

new
values for setting
code
code to execute in that environment
add
Combine with existing values? Currently for with_path only. If FALSE all existing paths are ovewritten, which don't you usually want.

Examples

Run this code
getwd()
in_dir(tempdir(), getwd())
getwd()

Sys.getenv("HADLEY")
with_env(c("HADLEY" = 2), Sys.getenv("HADLEY"))
Sys.getenv("HADLEY")

Run the code above in your browser using DataCamp Workspace