In R I would like to store a console command to a variable. I have already tried with the solutions proposed in the following link but without luck: In R, is it possible to redirect console output to a variable? Here you are the command I'm using:
test <- capture.output(system("pa11y scuolafalconeborsellino.it;
perl -e \"print unpack('c', pack('C', $?)), \\$/\""), file = NULL)
The output visiblein the console is:
[4m[36m Welcome to Pa11y[39m[24m [90mWe'll sniff your page for you now. [39m [36m > [39mLoading page... [36m > [39mRunning HTML CodeSniffer... [36m > [39m[31mError: HTML CodeSniffer error[39m
-1
but the variable test is empty.
Thank you!
system
has a parameter intern
which can be used to save the output to a character vector:
test <- system("pa11y scuolafalconeborsellino.it; perl -e \"print unpack('c', pack('C', $?)), \\$/\"",
intern = TRUE)
Note that system2
is now prefered and system
should be avoided in new code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With