I'm new to the list. I've used R and S-PLUS a bit for about 15 years but am now working to make R my main program for all numerical and statistical computing. I also use Octave for this kind of work and I recommend it (it is also under the GPL). Here's my question: In Octave I can write shell scripts in the Linux/UNIX environment that begin with a line like this... #!/usr/local/bin/octave -q ...and the remaining lines are octave commands. Is it possible to do this sort of thing in R using something like this?: #!/usr/lib/R/bin/R.bin Well, that isn't quite it because I tried it and it didn't work! Any advice greatly appreciated. Thanks in advance. Mike -- Michael B. Miller, Ph.D. Assistant Professor Division of Epidemiology and Community Health and Institute of Human Genetics University of Minnesota http://taxa.epi.umn.edu/~mbmiller/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This has been done and I said I would integrate it into R. It is on my list of things to do relatively soon. I have never been entirely happy with the way arguments are handled and that is what has put things on hold. And now that the R startup is a lot quicker, this is more worthwhile. Mike Miller wrote:> I'm new to the list. I've used R and S-PLUS a bit for about 15 years but > am now working to make R my main program for all numerical and statistical > computing. I also use Octave for this kind of work and I recommend it (it > is also under the GPL). Here's my question: In Octave I can write shell > scripts in the Linux/UNIX environment that begin with a line like this... > > #!/usr/local/bin/octave -q > > ...and the remaining lines are octave commands. Is it possible to do this > sort of thing in R using something like this?: > > #!/usr/lib/R/bin/R.bin > > Well, that isn't quite it because I tried it and it didn't work! > > Any advice greatly appreciated. Thanks in advance. > > Mike >- -- Duncan Temple Lang duncan at wald.ucdavis.edu Department of Statistics work: (530) 752-4782 371 Kerr Hall fax: (530) 752-7099 One Shields Ave. University of California at Davis Davis, CA 95616, USA -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDcAo19p/Jzwa2QP4RAjuPAJ48um++JJ9f1g62i6jBm7w8yZY7wwCfXU1J ceVWi2zr1oEcXV8BQyD2gdM=i8JE -----END PGP SIGNATURE-----
You can "cheat" by using the shell to write a small text file full of commands, then "source" that file by using R CMD BATCH yourtempfile.R . You can also write small text files with variables defined and values assigned, and pull them in from your script. On 11/7/05, Mike Miller <mbmiller@taxa.epi.umn.edu> wrote:> > I'm new to the list. I've used R and S-PLUS a bit for about 15 years but > am now working to make R my main program for all numerical and statistical > computing. I also use Octave for this kind of work and I recommend it (it > is also under the GPL). Here's my question: In Octave I can write shell > scripts in the Linux/UNIX environment that begin with a line like this... > > #!/usr/local/bin/octave -q > > ...and the remaining lines are octave commands. Is it possible to do this > sort of thing in R using something like this?: > > #!/usr/lib/R/bin/R.bin > > Well, that isn't quite it because I tried it and it didn't work! > > Any advice greatly appreciated. Thanks in advance. > > Mike > > -- > Michael B. Miller, Ph.D. > Assistant Professor > Division of Epidemiology and Community Health > and Institute of Human Genetics > University of Minnesota > http://taxa.epi.umn.edu/~mbmiller/ > > ______________________________________________ > R-help@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 >-- --------------------------------------- David L. Van Brunt, Ph.D. mailto:dlvanbrunt@gmail.com [[alternative HTML version deleted]]
On 7 Nov 2005, Mike Miller wrote:> Is it possible to do this sort of thing in R using something like this?: > > #!/usr/lib/R/bin/R.bin > > Well, that isn't quite it because I tried it and it didn't work!Mike, I use a shell script to do this which also allows passing in command line options. http://www.biostat.umn.edu/~nali/computing/Rstuff.html#sec2 It is a hack of course. Hopefully soon this will be implemented in R itself. Michael
Use the all powerful "here document" feature of bash: R --vanilla << "EOF" # Pipe all subsequent lines into R. ####### Here's my R code require(tcltk) tkmessageBox(message="It works") ###### the end EOF Mike Miller wrote:> I'm new to the list. I've used R and S-PLUS a bit for about 15 years but > am now working to make R my main program for all numerical and statistical > computing. I also use Octave for this kind of work and I recommend it (it > is also under the GPL). Here's my question: In Octave I can write shell > scripts in the Linux/UNIX environment that begin with a line like this... > > #!/usr/local/bin/octave -q > > ...and the remaining lines are octave commands. Is it possible to do this > sort of thing in R using something like this?: > > #!/usr/lib/R/bin/R.bin > > Well, that isn't quite it because I tried it and it didn't work! > > Any advice greatly appreciated. Thanks in advance. > > Mike >