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
shell scripts in R
12 messages · Marco Grazzi, Gabor Grothendieck, Andrew Robinson +8 more
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
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 !
Don't you mean system("ls")? See ?system.
Arguments:
command: the system command to be invoked, as a string.
--sundar
On Fri, 2005-10-14 at 00:04 +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 !
As per ?system:
command the system command to be invoked, as a string.
Thus,
system("ls", intern = FALSE, ignore.stderr = TRUE)
HTH,
Marc Schwartz
Dnia pi??tek, 14 pa??dziernika 2005 00:13, Sundar Dorai-Raj napisa??:
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 is writing the documentation for R, please do not attempt to save on bytes. Life would be so much more pleasureable.... if only it would say "as a quoted string". Jee.
Benedict Cyfrowy klucz publiczny / Digital public key http://agrypa1.atspace.com/klucze/kb2qzv_wp.pl-public.asc
Le 13 Octobre 2005 18:39, Benedict P. Barszcz a ??crit??:
Dnia pi??tek, 14 pa??dziernika 2005 00:13, Sundar Dorai-Raj napisa??:
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 is writing the documentation for R, please do not attempt to save on bytes. Life would be so much more pleasureable.... if only it would say "as a quoted string". Jee.
In 'system(ls)', 'ls' would be any object, whereas in 'system("ls")', it is a
string. Specifying "quoted string" would be redundant. (True R wizard can
correct me if I,m not accurate.)
When I first encountered R's man pages, I thought they were rather sparse
compared to those of S-Plus. Now I find they are just to the point and so
much easier to consult!
Vincent Goulet, Professeur agr??g?? ??cole d'actuariat Universit?? Laval, Qu??bec Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca
On Fri, 2005-10-14 at 00:39 +0200, Benedict P. Barszcz wrote:
Dnia piÂÄ…tek, 14 paÂździernika 2005 00:13, Sundar Dorai-Raj napisaÂÅ‚:
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 is writing the documentation for R, please do not attempt to save on bytes. Life would be so much more pleasureable.... if only it would say "as a quoted string". Jee.
The phrase "quoted string" in my mind is redundant. If you had taken the time to review the 3 examples provided on the same page, you would have seen that all three show the use of quotes around the command and indeed two of the three use the 'ls' command specifically. Marc Schwartz
First I have to correct myself; there probably is an ls object in your
workspace, but it's a function.
Second I have to suggest you should try to run the example code in the
help file. Surely this would clarify that the string has to be
quoted?
t1 <- system("who", TRUE)
I'm not so sure that it's a question of saving bytes as a question of
assuming that people will try reasonable avenues.
Cheers
Andrew
On Fri, Oct 14, 2005 at 12:39:59AM +0200, Benedict P. Barszcz wrote:
Dnia pi?tek, 14 pa?dziernika 2005 00:13, Sundar Dorai-Raj napisa?:
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 is writing the documentation for R, please do not attempt to save on bytes. Life would be so much more pleasureable.... if only it would say "as a quoted string". Jee. -- Benedict Cyfrowy klucz publiczny / Digital public key http://agrypa1.atspace.com/klucze/kb2qzv_wp.pl-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
But,
> foo <- 'ls'
> system(foo)
is valid.
Is foo a "string" or a "quoted string"?
Without a doubt, it is the former. But I don't see any quote marks in
system(foo)
-Don
At 12:39 AM +0200 10/14/05, Benedict P. Barszcz wrote:
Dnia pi??tek, 14 pa??dziernika 2005 00:13, Sundar Dorai-Raj napisa??:
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 is writing the documentation for R, please do not attempt to save on bytes. Life would be so much more pleasureable.... if only it would say "as a quoted string". Jee. -- Benedict Cyfrowy klucz publiczny / Digital public key http://agrypa1.atspace.com/klucze/kb2qzv_wp.pl-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
-------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA
An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20051014/28a2f663/attachment.pl