Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

using_something

Execute code in temporarily altered environment.


Description

These functions were extracted from the devtools package to make them available without a dependency to devtools.

Usage

using_envvar(new, code, action = "replace")

using_env(new, code)

using_locale(new, code)

using_collate(new, code)

using_dir(new, code)

using_libpaths(new, code)

using_lib(new, code)

using_options(new, code)

using_par(new, code)

using_path(new, code, add = TRUE, prepend = FALSE)

Arguments

new

values for setting

code

code to execute in that environment

action

(for using_envvar only): should new values "replace", "suffix", "prefix" existing environmental variables with the same name.

add

Combine with existing values? Currently for using_path only. If FALSE all existing paths are overwritten, which you don't usually want.

prepend

logical that indicates if the new paths should be added in front of the current ones.

Details

  • using_dir: working directory

  • using_collate: collation order

  • using_envvar: environmental variables

  • using_libpaths: library paths, replacing current libpaths

  • using_lib: library paths, prepending to current libpaths

  • using_locale: any locale setting

  • using_options: options

  • using_path: PATH environment variable

  • using_par: graphics parameters

Deprecation

using_env will be deprecated in devtools 1.2 and removed in devtools 1.3

Author(s)

Hadley Wickham

Examples

getwd()
using_dir(tempdir(), getwd())
getwd()

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

using_envvar(c("A" = 1),
  using_envvar(c("A" = 2), action = "suffix", Sys.getenv("A"))
)

pkgmaker

Development Utilities for R Packages

v0.32.2
GPL (>= 2)
Authors
Renaud Gaujoux [aut, cre]
Initial release
2020-10-20

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.