with_connection {withr} | R Documentation |
Connections which close themselves
Description
R file connections which are automatically closed.
Usage
with_connection(con, code)
local_connection(con, .local_envir = parent.frame())
Arguments
con |
For |
code |
|
.local_envir |
|
Value
[any]
The results of the evaluation of the code
argument.
See Also
withr
for examples
Examples
with_connection(list(con = file("foo", "w")), {
writeLines(c("foo", "bar"), con)
})
read_foo <- function() {
readLines(local_connection(file("foo", "r")))
}
read_foo()
unlink("foo")
[Package withr version 3.0.0 Index]