Is there a way to run an executable from R and capture its output?
As an example:
output <- run_exe("my.exe")
In fact, you can take any R script and compile it into a report that includes commentary, source code, and script output. Reports can be compiled to any output format including HTML, PDF, MS Word, and Markdown. The first call to render creates an HTML document, whereas the second creates a PDF document.
Use the Rscript executable that runs at command line (cmd, Powershell, Bash, etc.): Rscript /path/to/my/Rscript. R . No R app launches or opens in background.
The most convenient way to run R scripts from the command line is to use Rscript, an alternative front-end to run R code. Rscript is capable of executing R code from different command interpreters, such as a bash script on Linux or a Task Scheduler task on Windows.
Yes, look at system()
and its options. Hence
R> res <- system("echo 4/3 | bc -l", intern=TRUE)
R> res
[1] "1.33333333333333333333"
R>
would be one way to divide four by three in case you mistrust the R engine itself.
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