I'm trying to get the output from a binary with args called by system2 into an R object. But, I fail. I've googled for several alternatives such as system, exec_internal but cannot get it right. Here is a toy example using Linux' function "factor" which should factorize 5555.
test_001 <- system2("factor", args=c("5555"))
and the output shown on the monitor is
5555: 5 11 101
However, I would like to have that result into the object "test_001". But if I type
test_001
the result is only
[1] 0
I really don't understand how to get the output from system2 into an R object. Thanks for any help!
You have to change the location where the output is sent to by specifying
stdout(and possiblyetderr) option. As the help of system2 indicates the default output is R consoleoutput = TRUEsend the output as a character vector object in R. So for your case you can: