How to save console output to a variable in R

In R, I would like to save the console command for the variable. I already tried with the solutions suggested in the following link, but no luck: In R, is it possible to redirect console output to a variable? Here you are using the command that I am using:

test <- capture.output(system("pa11y scuolafalconeborsellino.it; perl -e \"print unpack('c', pack('C', $?)), \\$/\""), file = NULL) 

The console displays:

[4m [36m Welcome to Pa11y [39m [24m [90 m. We are now sniffing your page for you. [39m [36m> [39mLoading page ... [36m> [39mRunning HTML CodeSniffer ... [36m> [39m [31mError: HTML CodeSniffer error [39m

1

but the variable check is empty.

Thanks!

+5
source share
1 answer

system has an intern parameter that can be used to save output to a character vector:

 test <- system("pa11y scuolafalconeborsellino.it; perl -e \"print unpack('c', pack('C', $?)), \\$/\"", intern = TRUE) 

Please note that now system2 preferable and system should be avoided in the new code.

+6
source

All Articles