Consider the following cross-platform test:
> system('echo hello')
hello
If in RStudio I copy the string system('echo hello')
and the run reprex::reprex()
the output is not captured:
Is there any way to capture the output? I'm on macOS.
Perhaps setting std_out_err = TRUE
does the job. From the function documentation:
std_out_err Logical. Whether to append a section for output sent to stdout and stderr by the reprex rendering process. This can be necessary to reveal output if the reprex spawns child processes or system() calls. Note this cannot be properly interleaved with output from the main R process, nor is there any guarantee that the lines from standard output and standard error are in correct chronological order. See callr::r() for more. Read more about opt().
system("echo hello")
x <- 1
x
#> [1] 1
standard output and standard error
hello
Created on 2019-06-24 by the reprex package (v0.3.0)