Unable to get R language system2 command result

前端 未结 2 513
眼角桃花
眼角桃花 2021-02-07 22:34

i am not able to get the system2 result. tried to execute the sample jar file.

execute_system.R:

workingDir <- \"C:/Code\"
setwd(work         


        
2条回答
  •  甜味超标
    2021-02-07 23:05

    Using your code, it worked for me without error when I did the following:

    system2('java', args = c('-jar', 'sample.jar', '123'),
             stdout = 'stdout.txt', stderr = 'stderr.txt')
    

    I ran this on Mac OSX 10.10.5 (Yosemite). The results were printed to "stdout.txt".

    It seems from the documentation for system2, the first option is just a command (i.e. no arguments). The arguments are to be specified with the args parameter.

    Here is a snippet from the Details section:

    Details

    Unlike system, command is always quoted by shQuote, so it must be a single command without arguments.

    ...

提交回复
热议问题