Search code examples
rsystem2

system2 functioning in R


When I run a batch file through system2 in R:

The following runs the batch file without any issue:

system2("Run.bat")

However, this one gives an error:

system2("Run", stdout=stdout, stderr=stderr)
Warning message:
running command '"Run.bat"' had status 1 

Any insights on what might be causing this?


Solution

  • Read the documentation carefully:

    stdout, stderr where output to ‘stdout’ or ‘stderr’ should be sent. Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file.

    Seems like you need to specify those arguments as character strings.