Here is an example:
RR <- "/usr/bin/R"
x <- system2(RR, "--version")
R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.
> x
[1] 0
As you can see here the x is 0
. My question is how to assign the system2(RR, "--version")
output to x
.
This is described in the documentation for ?system2
. If you want to capture the output of your program as a character vector, set stdout=TRUE
x <- system2(RR, "--version", stdout=TRUE)
"stdout" is for the "standard output" of the program. It's a common term used by programs to identify the "result" from a program.
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