[R] Command Line Programs

Andy Bunn abunn at montana.edu
Thu Mar 4 23:52:23 CET 2004


?source

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> Kissell, Robert [EQRE]
> Sent: Thursday, March 04, 2004 3:19 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Command Line Programs
> 
> 
> Hi,
> I have recently started using R again (switched from MatLab) 
> and have a question regarding programming. How can I set up a 
> file that will run several lines of R code? For example, in 
> Fortran and DOS this used to be done via a batch file, and in 
> MatLab I would write the code and save it in a script file, 
> e.g., Test.m.
> 
> An example of what I am trying to do is the following:
> 
> x=matrix(c(1,2,3,4,5,6,7,8,9),3,3)
> y=matrix(c(rnorm(9),3,3)
> z1=x*y
> z2=x%*%y
> 
> eigen(z1)
> eigen(z2)
> 
> 
> I would like to store these commands in a file and simply 
> run/call/invoke that file rather than have to type in the 
> line commands everyday. The above is a very simple snapahot 
> of what I am doing.
> 
> Right Now I have a function that runs these commands. Also, I 
> can easily COPY the commands from some editor (e.g., Word) 
> and PASTE to the R Console, and R will automatically run the commands.
> 
> The question is, Is there anyway to invoke a series of 
> commands outside of the function? In MatLab, as I mentioned, 
> I would save the commands in a script file say TEST.m and run 
> the commands from the MatLab command line prompt simply by 
> typing TEST <enter>.
> 
> Thanks in advance.
> 
> 
> Rob
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
> PLEASE 
> do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
>




More information about the R-help mailing list