r2dup2
Using r2dup2 and its resultIn R, the default utils::capture.output function only redirects R
messages: it does not truly redirect the system streams, and thus fails with
sub-processes, such as pandoc when using RMarkdown.
r2dup2 provides a way to truly redirect the error stream (stderr),
by using the with_redirect_stderr function:
r2dup2::with_redirect_stderr(file = "error.txt", {
system("echo >&2 This line will be printed to error.txt")
})
r2dup2 is only available on GitHub, install it with the remotes package:
install.packages("remotes")
remotes::install_github("rchaput/r2dup2")