Capture and live display of system2 command in R console

Capture and live display of system2 command in R console
I want to run a command and see the live progress in the console and capturing the result of it at the same time, either local vector or external file. In windows: system2('Rscript', args = c('-e', '"for(i in 1:10){Sys.sleep(2);print(as.character(Sys.time()))}"')) This prints a string every 2 seconds, 10 times. My real application will display a longer message. I tried system( ) but can't make it show the progress system2 shows the progress (essential for me), and I also want to save that output somewhere. I tried using this appraches that saved the output but did not show progress: capture.output ( ) mylog = system2( ... , stdout = TRUE) system2( ... , stdout = 'mylog.txt') Any ideas of doing both things at the same time: Showing progress and storing the output? Highly appreciated a multi-platform solution

Take Your Experience to the Next Level

New

Download our mobile app for a faster and better experience.

Comments

0
U

Join the discussion

Sign in to leave a comment

0:000:00
Capture and live display of system2 command in R console