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 2011However 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] 0How do i capture the return of system()? Thanks R-world, John Dennison [[alternative HTML version deleted]]
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 DennisonSee 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
Seemingly Similar Threads
- Parametrized object name in Save statement
- Possible bug in `class<-` when a class-specific '[[.' method is defined
- Change in package.skeleton behavior from R 3.6.3 to R 4.0.0 ?
- Codificacion de caracteres
- A question about using getSrcDirectory() with R/Rscript