defer() and all
local_*() functions now work when run inside of
.Rmd. The deferred expressions are executed when knitr exits.
local_ functions now work within
The deferred expressions are executed when
local_() gain a
get argument. Supply a getter
function to create
local functions that are robust to
When supplied, this restoration pattern is used:
old <- get()
old <- set(new)
This ensures proper restoration of the old state when an early exit
set() (for instance when a deprecation warning is
caught, see #191).
local_ functions are now robust to early exits (see next bullet):
local_namespace() now pass
attach() (@kyleam, #185).
local_seed() no longer warn when
with_seed() now preserves the current values of
with_collate() is no longer affected by the
environment variable set to "C" (#179).
Local evaluations in the
globalenv() (as opposed to top-level
ones) are now unwound in the same way as regular environments.
local_tempfile() gains a lines argument so, if desired, you can pre-fill
the temporary file with some data.
Lionel Henry is the new maintainer.
Handlers registered with the global environment (as happens when
is run at the top-level, outside a function) are now automatically run
when the R session ends (#173).
local_language() to temporarily control the
language used for translations (#180).
with_seed() now caches the check for R version, so is now faster (#170)
local_makevars() now eagerly evaluate the
path argument (#169)
local_options() now lets you set an option to
NULL as intended (#156)
envir is deprecated, in favor of
All withr functions except
.local_envir to specify environments, so this makes this function consistent with the rest. (#157)
with_environment() now passing
attach(), as intended (#161).
with_seed() now also sets the RNG via new arguments
with_timezone() now works after recent changes to
Sys.timezone() in R-devel (#165)
capabilities("cairo")are now skipped.
withr is now licensed as MIT (#154).
with_cairo_ps() have been removed, as they fail if Cairo is not available, such as with M1 macOS systems (#158)
local_seed() is now exported (#153)
newis deprecated, in favor of returning the path to the new tempfile. calls like
local_tempfile("xyz")should be replaced with
xyx <- local_tempfile()in your code (#141).
local_seed() function and
local_preserve_seed() functions to correspond to
local_tempdir() function added to create a temp directory (#140)
local_*() functions now take dots (
...), which can simplify calls in some cases, e.g. you can now use
local_options(foo = "bar") rather than
local_options(c(foo = "bar")).
defer() now throws an error if an error occurs in the deferred expression (#148)
local_file() can now work if the file is actually a directory (#144).
defer() can set deferred events on
.GlobalEnv to facilitate the interactive development of code inside a function or test.
deferred_clear()) provide a way to explicity run and clear (or just clear) deferred events (#76, @jennybc).
with_connection() now works when existing objects or connections exist with the same names (#120)
with_makevars() now uses
tools::makevars_user() to determine the default user makevars file (#77, @siddharthab).
with_options() no longer uses
do.call(), so optiosn are not evaluated on exit (#73, @mtmorgan).
with_package() no longer has the
help argument (#94, @wendtke).
with_package() now does not try to detach the package if it is already attached before calling
with_preserve_seed() now restores
.Random.seed if it is not set
local_rng_version() functions to change the version of the RNG (#90, @gaborcsardi).
with_svg() documentation now is consistent across R versions (#129)
local_timezone() functions to change the time zone (#92, @gaborcsardi).
local_tempfile() now delete recursively directories on exit (#84, @meta00).
set_makevars() is now exported (#68, @gaborcsardi).
with_temp_libpaths() gains an
action argument, to specify how the
temporary library path will be added (#66, @krlmlr).
Fixes test failures with testthat 2.0.0
with_file() function to automatically remove files.
with_connection() function to automatically close R file connections.
with_db_connection() function to automatically disconnect from DBI database
with_gctorture2 command to run code with gctorture2, useful for testing
with_environment() (and equivalent
locals) functions added, to run code with a modified object search path (#38,
local_tempfile() functions to create temporary
files which are cleanup up afterwards. (#32)
code argument from
local_ functions (#50).
with_ function now has a
local_ variant, which reset at the end of
their local scope, generally at the end of the function body.
with_preserve_seed() for running code with
a given random seed (#45, @krlmlr).
assignmentargument to allow specifying additional assignment types.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.