On Jun 30, 2011, at 4:55 PM, John Dennison wrote:
> To get the tech specs out of the way I am running Rstudio(R 2.13.0) on a
> ubuntu box. I am trying to use information returned from the system command
> within an Rscript. System() passes commands to my ubuntu prompt and returns
> the normal messages.
> For example.
>
>> system("date")Thu Jun 30 21:48:20 UTC 2011
>
> However when i try to store this return(something i need to do for my
> purposes) nothing is stored(or at least not what shown on the R prompt)
>
>> store<-system("date")Thu Jun 30 21:49:27 UTC 2011>
store[1] 0
>
> How do i capture the return of system()?
>
> Thanks R-world,
>
> John Dennison
See the 'intern' argument:
> system("date", intern = TRUE)
[1] "Thu Jun 30 17:06:12 CDT 2011"
This returns a character vector of the results of the command executed.
HTH,
Marc Schwartz