Displaying 1 result from an estimated 1 matches for "opwd".
Did you mean:
opad
2013 Nov 03
1
WISHLIST: on.exit(..., add=TRUE, where="first") to address common use cases
...ression should be
added before or after already recorded expression. The default is now
to add it after, but it would often be useful to add it before
previously recorded expressions.
EXAMPLE:
foo <- function(path="work") {
# Change working directory. Make sure to reset on exit.
opwd <- setwd(path)
on.exit(setwd(opwd))
# Write to a local temporary file. Make sure to remove it on exit.
cat("Hello", file="local.txt")
on.exit(file.remove("local.txt"), add=TRUE, where="first")
}
Without where="first" (i.e. using where=...