Change the working directory, evaluate the expression, and restore the
working directory.
Arguments
- dir
Path to a directory.
- expr
An R expression.
Examples
library(xfun)
in_dir(tempdir(), {
print(getwd())
list.files()
})
#> [1] "/tmp/RtmpFJzAzX"
#> [1] "bslib-2b54cdf606b7b99ac32b99843ce2e662"
#> [2] "downlit"
#> [3] "file949dd2d7944e6"
#> [4] "file949dd3748d481"
#> [5] "file949dd5c689a7e"