[R] write R scripts

Ott Toomet siim at obs.ee
Tue Sep 17 07:30:37 CEST 2002


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list