[R] how to run system command

Henrik Bengtsson hb at biostat.ucsf.edu
Wed Mar 7 00:52:24 CET 2012


On Tue, Mar 6, 2012 at 11:49 AM, William Dunlap <wdunlap at tibco.com> wrote:
>> system("cmd.exe /c date /T", intern=TRUE)
> [1] "Tue 03/06/2012 "

To avoid messing with "cmd.exe /c", you can use shell(), e.g.

> res <- shell("date /T", intern=TRUE)
> res
[1] "Tue 03/06/2012 "


>
> Bill Dunlap
> Spotfire, TIBCO Software
> wdunlap tibco.com
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of sagarnikam123
>> Sent: Tuesday, March 06, 2012 5:49 AM
>> To: r-help at r-project.org
>> Subject: Re: [R] how to run system command
>>
>> i used it on windows system, but giving error like
>>
>> > e <- system("date", intern=TRUE)
>> Error in system("date", intern = TRUE) : 'date' not found
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/how-to-run-system-command-
>> tp4449597p4449906.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list