Hi, I've just started using R and my question is basic I think. Instead of typing each time a lot of lines I'd like to write a script, which basically takes as input a data file and outputs a graph. Something like: data2graph input.txt I know the commands I need to type but I don't know how to write such a script. Should I use a specific software? Thanks for your help Vincent -- Vincent Plagnol University of Southern California, DRB 271 Phone: (213) 740 2398 Home: 345 South Alexandria #405 CA 90020, Los Angeles Phone: (213) 386 3364 En France: 6 avenue Gambetta 78100 Saint Germain en Laye Tel: (01) 30 61 21 89 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Vincent, I think source() is what you are looking for. The only "specific software" is a text editor (gedit should do, you seem to be using GNOME), you have to write exactly the same commands in a file and then say> source("myfile.R")if your script lies in the current directory. A better way is to define a function. You can write it with an editor as before (read Introduction to R for how to define a function), source() the file and run the function as e.g.> data2graph("input.txt")Probably the best way is using Emacs and ESS. It does basically source()-ing too, but it is much more easy to source an emacs buffer to R with only couple of keystrokes. And ESS offers much more than just that, e.g. syntax coloring and completion of R objects. But emacs needs some time to be familiar with. Perhaps it helps. Ott On 16 Sep 2002, Vincent Plagnol wrote: | |Hi, | |I've just started using R and my question is basic I think. Instead of |typing each time a lot of lines I'd like to write a script, which |basically takes as input a data file and outputs a graph. |Something like: | |data2graph input.txt | |I know the commands I need to type but I don't know how to write such a |script. Should I use a specific software? Thanks for your help | |Vincent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Vincent Plagnol wrote:> > Hi, > > I've just started using R and my question is basic I think. Instead of > typing each time a lot of lines I'd like to write a script, which > basically takes as input a data file and outputs a graph. > Something like: > > data2graph input.txt > > I know the commands I need to type but I don't know how to write such a > script. Should I use a specific software? Thanks for your helpI guess you are going to write a --- function ? You'll find how to write a function in the docs... Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._