withr v1.0.2

0

Monthly downloads

0th

Percentile

by Jim Hester

Run Code 'With' Temporarily Modified Global State

A set of functions to run code 'with' safely and temporarily modified global state. Many of these functions were originally a part of the 'devtools' package, this provides a simple package with limited dependencies to provide access to these functions.

Readme

Withr - Run Code 'With' Modified State

Travis-CI Build Status AppVeyor Build Status Coverage Status CRAN Version

A set of functions to run code 'with' safely and temporarily modified global state.

Many of these functions were originally a part of the devtools package, this provides a simple package with limited dependencies to provide access to these functions.

  • with_collate() - collation order
  • with_dir() - working directory
  • with_envvar() - environment variables
  • with_libpaths() - library paths
  • with_locale() - any locale setting
  • with_makevars() - Makevars variables
  • with_options() - options
  • with_par() - graphics parameters
  • with_path() - PATH environment variable

There is also a with_() function to construct new with_* functions if needed.

dir.create("test")
#> Warning in dir.create("test"): 'test' already exists
getwd()
#> [1] "/tmp/RtmpaPrDI5"
with_dir("test", getwd())
#> [1] "/tmp/RtmpaPrDI5/test"
getwd()
#> [1] "/tmp/RtmpaPrDI5"
unlink("test")

Sys.getenv("HADLEY")
#> [1] ""
with_envvar(c("HADLEY" = 2), Sys.getenv("HADLEY"))
#> [1] "2"
Sys.getenv("HADLEY")
#> [1] ""

with_envvar(c("A" = 1),
  with_envvar(c("A" = 2), action = "suffix", Sys.getenv("A"))
)
#> [1] "1 2"

See Also

Functions in withr

Name Description
withr Execute code in temporarily altered environment
with_ Create a new "with" function
No Results!

Last month downloads

Details

Encoding UTF-8
URL http://github.com/jimhester/withr
BugReports http://github.com/jimhester/withr/issues
License GPL (>= 2)
LazyData true
Collate 'with_.R' 'collate.R' 'dir.R' 'env.R' 'libpaths.R' 'locale.R' 'makevars.R' 'options.R' 'par.R' 'path.R' 'wrap.R' 'sink.R' 'with.R'
RoxygenNote 5.0.1
NeedsCompilation no
Packaged 2016-06-20 12:49:55 UTC; jhester
Repository CRAN
Date/Publication 2016-06-20 17:32:02

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/withr)](http://www.rdocumentation.org/packages/withr)