Search code examples
rmacossystem

how to store the response of a system call from R studio to Mac OS X


Not sure how to best ask this. I want to store the response of a system command in R studio Mac.

For example, this command:

system("pwd")

Returns this:

/Volumes/chart/chart

I would like to store the return in a variable like this:

result <- system("pwd")

but this does not work.


Solution

  • Use the intern parameter.

    result <- system('pwd', intern = T)
    result
    #> [1] "/Volumes/chart/chart"