Hi, How can I execute some scripts from within R. I have a large data file which I process (for instance with gawk, but not only) before performing some statistics. I would like to do this in R, so that I do not have to save many data files and then making analysis on them (which proved to be unefficient) Thank you Marco Grazzi
Look at the example that uses gawk and pipe in: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/59815.html On 10/13/05, Marco Grazzi <grazzi at sssup.it> wrote:> > Hi, > > How can I execute some scripts from within R. > I have a large data file which I process (for instance with gawk, but not > only) before performing some statistics. > I would like to do this in R, so that I do not have to save many data files > and then making analysis on them (which proved to be unefficient) > > Thank you > > Marco Grazzi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Marco, use the system command. ?system I hope that this helps, Andrew On Thu, Oct 13, 2005 at 05:14:38PM -0400, Marco Grazzi wrote:> > Hi, > > How can I execute some scripts from within R. > I have a large data file which I process (for instance with gawk, but not > only) before performing some statistics. > I would like to do this in R, so that I do not have to save many data files > and then making analysis on them (which proved to be unefficient) > > Thank you > > Marco Grazzi > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and Statistics Fax: +61-3-8344-4599 University of Melbourne, VIC 3010 Australia Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au
Dnia czwartek, 13 pa??dziernika 2005 23:25, Andrew Robinson napisa??:> Marco, > > use the system command. > > ?system > > I hope that this helps,system(ls, intern = FALSE, ignore.stderr = TRUE) Error in as.character(args[[i]]) : cannot coerce to vector In fact it ignores the stderr ! -- pozdrawiam, Benedykt Cyfrowy klucz publiczny / Digital public key http://agrypa1.atspace.com/klucze/kb2qzv_onet-public.asc
On Fri, 2005-10-14 at 00:04 +0200, Benedykt P. Barszcz wrote:> Dnia czwartek, 13 padziernika 2005 23:25, Andrew Robinson napisa: > > Marco, > > > > use the system command. > > > > ?system > > > > I hope that this helps, > > system(ls, intern = FALSE, ignore.stderr = TRUE) > Error in as.character(args[[i]]) : cannot coerce to vector > > In fact it ignores the stderr !As per ?system: command the system command to be invoked, as a string. Thus, system("ls", intern = FALSE, ignore.stderr = TRUE) HTH, Marc Schwartz
Benedykt, No, there is no ls object in your workspace. Try this: system("ls", intern = FALSE, ignore.stderr = TRUE) Andrew On Fri, Oct 14, 2005 at 12:04:52AM +0200, Benedykt P. Barszcz wrote:> Dnia czwartek, 13 pa?dziernika 2005 23:25, Andrew Robinson napisa?: > > Marco, > > > > use the system command. > > > > ?system > > > > I hope that this helps, > > system(ls, intern = FALSE, ignore.stderr = TRUE) > Error in as.character(args[[i]]) : cannot coerce to vector > > In fact it ignores the stderr ! > -- > pozdrawiam, > Benedykt > > Cyfrowy klucz publiczny / Digital public key > http://agrypa1.atspace.com/klucze/kb2qzv_onet-public.asc > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html-- Andrew Robinson Senior Lecturer in Statistics Tel: +61-3-8344-9763 Department of Mathematics and Statistics Fax: +61-3-8344-4599 University of Melbourne, VIC 3010 Australia Email: a.robinson at ms.unimelb.edu.au Website: http://www.ms.unimelb.edu.au
>>>> Marc Schwartz <MSchwartz at mn.rr.com> 10/13/05 06:07PM >>> >On Fri, 2005-10-14 at 00:39 +0200, Benedict P. Barszcz wrote: >> Dnia piatek, 14 pazdziernika 2005 00:13, Sundar Dorai-Raj napisal: >> >> > Don't you mean system("ls")? See ?system. >> > >> > Arguments: >> > >> > command: the system command to be invoked, as a string. >> >> This is the kind of obstacles a newbie has to overcome. Whoeve iswriting the>> documentation for R, please do not attempt to save on bytes. Lifewould be so>> much more pleasureable.... if only it would say "as a quotedstring". Jee.> >The phrase "quoted string" in my mind is redundant.It is also inaccurate, after all you could do the following:> tmp <- paste(letters[ c(12,19)], collapse='') > system(tmp,show=T)here tmp is a string and works, but quoting it would break things. Greg Snow, Ph.D. Statistical Data Center, LDS Hospital Intermountain Health Care greg.snow at ihc.com (801) 408-8111