Try this: A <- 1 B <- 2 C <- 3 source("myfile.R")
Now the code in myfile can access A, B and C. On Tue, Feb 17, 2009 at 10:55 AM, <mau...@alice.it> wrote: > A couple of weeks ago I asked how it is possible to run an R script (not a > function) passing some parameters. > Someone suggested the function "commandArgs()". > I read the on-line help and found no clarifying example. Therefore I do not > know how to use it appropriately. > I noticed this function returns the pathname of the R executable which is not > what I need. > > I meant to ask if it is possible to open an R session and launch a script > passing parameters that the script can retrieve and use itself. > Just like in C I can run a program and call it with some arguments > >> Example_Prog A B C > > The program "Example_Prog" can acess its own arguments through the data > structures "argc" an "argv". > > How can I launch an R script simulating the above mechanism ? > Shall I use source ("script-name") ? > Where are the arguments to be passed, as part of the source call ? > Is the function "commandArgs" to be places as one of the first code lines of > the script in order to access its own arguments ? > Is there any "commandArgs" usage example ? > > Thank you very much in advance. > Maura > > > > > > > tutti i telefonini TIM! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.