Base R function system2 is the recommended way of invoking an operating system command from within R. It is portable across operating systems. Note that system2() never returns anything, to capture the OS command output in a character variable in the R session, arguments stdout or stderr must be set to TRUE.
Questions tagged [system2]
35 questions
1
vote
1 answer
Using system2() in R to run compiled cpp file
I'm trying to run a compiled cpp file in my R program using system2(). The documentation for the cpp suggests that it's just one big command, so I'm thinking I'm not supposed to use the stdout or stder options in sys2.
the required network.nodes…

D Schiff
- 91
- 9
1
vote
1 answer
Pass output from system2 into R object
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"…

itio
- 33
- 3
1
vote
0 answers
system2 command not found
I am trying to count the number of words in a twitter file using the expression
system2("wc", args = "-w final/en_US/en_US.news.txt",stdout=TRUE)
I keep getting a message that
Error in system2("wc", args = "-w final/en_US/en_US.news.txt",…

Rnovice
- 11
- 1
1
vote
1 answer
R system2 trouble invoking R script on windows
I frequently use RODBC to connect with Microsoft Access databases and can only do this in 32-bit R because 32 bit MS Office is loaded on my Windows 7 PC.
After extracting my data from an MS access database in 32-bit R, I usually then want to…

Amy M
- 967
- 1
- 9
- 19
1
vote
0 answers
R Wait until system executable is finished
I am trying to run a series of input files (located in my C:/GenSoftware/Colony/datFiles/ directory) through an executable Colony2.exe that is located in my C:/GenSoftware/Colony/ directory. I attempt to rename file 1, copy it to the same directory…

mackerman
- 11
- 1
- 2
0
votes
0 answers
run external script by system2 in R
I have Shiny App, one of its functionalities is to run an external script in separate session. I do it with the code:
system2(command = "RScript", args = c("--vanilla", "external_script.r"), wait = FALSE)
This works fine when the external_script.R…

tomsu
- 371
- 2
- 16
0
votes
0 answers
issue running command using system or system2 in R
Not my area of expertise, so apologies in advance. I am trying to run a command through system2() in R
The "planet" command (python program) works fine when typed directly in CMD:
F:\>planet --version
>1.5.2
However, I can't get it to recognize the…

mikealonzo47
- 31
- 3
0
votes
1 answer
R studio isn't running a program using system2(), how can I get it to run my program?
I am trying to run a compiled program (idemp - https://github.com/yhwu/idemp ) from a script in R Studio. I just installed the latest version of R studio and R on November 15, 2021 four days ago.
I followed the directions on the idemp page to…

aminards
- 309
- 2
- 11
0
votes
1 answer
How to fix a problem with Cyrillic symbols (cmd system commands)?
In my previous post, I brought up a question about Cyrillic symbols in R.
Today I have faced another one.
For example, we want to see our running processes:
test <- system2(command="tasklist",
stdout=TRUE,
…

manro
- 3,529
- 2
- 9
- 22
0
votes
0 answers
R System command working in R studio, but its not working in Rescript batch mode, is there any method to invoke vbs script from Rescript mode?
I have below code in new.R file, which is working fine in RStudio interactive mode.
system_command <- paste("WScript", " C:/Users/OneDrive/Desktop/r1.vbs")
system(command = system_command)
But when I run the new.R file using Rscript, its not…
0
votes
0 answers
Unable to git add using system2 from R script
I am trying to add a file using git add. Note: I am very new to git.
Using Ubuntu Linux
From a terminal prompt, this works.
/usr/bin/git add static/fb/img/gic1-5_yield_curve_5bd11b935bd72745.png
I can confirm that it works by doing git status and…

ixodid
- 2,180
- 1
- 19
- 46
0
votes
0 answers
How can I use system or system2 if the command has pipe to head like "cmd | head"
I noticed that when I run a long command in linux (I am using a cantos 7.3 distro, R 4.0.3 on the terminal) and that I pipe to head only the first outputs are shows to me (and the command stops)
ls -R /opt # on my system I would get tons of…

statquant
- 13,672
- 21
- 91
- 162
0
votes
1 answer
R system or system2 command using paste or sprintf to run bat file?
I have a bat file that I can run from R using the following system command:
system('"C:\\PROGRA~1\\THERMO~1\\AFFYME~1\\APT-12~1.5\\bin\\apt-vars.bat" && cd "C:\\Users\\phyca\\Desktop\\R7\\R7_10-~1" && apt-cel-convert.exe --f text --i --cel-files…

Steve
- 588
- 4
- 17
0
votes
0 answers
How to use system2 function properly
I am writing the script for analyzing data in which I am using the system2 function. I should hope, that my function is proper.
My function returns the problem:
Class 'try-error' atomic [1:1] Error in system2(file.path(script.dir, "script1.sh"),…

bwczech
- 21
- 4
0
votes
1 answer
Different results for same function when parallel R computation
I have an issue with invoke an external batch using system2 function with parallel library under Windows 10, my function execute a external program to read a binary file (must be content in the same folder as example). The issue is myfunction…

Fidel Maureira
- 1
- 1