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/Rtmp6t5Oa2"
#> [1] "bslib-60f3cf8b58e87c609cae53b52776d76c"
#> [2] "downlit"
#> [3] "file8bf2f308640a6"
#> [4] "file8bf2f3ce8971c"
#> [5] "file8bf2f546d10cc"