dear R group: I have the probably fairly common problem that I would like to have one code.R file do different things if it is invoked from a symbolic link, which should be easy to uncover. $ ln -s code.R code-0.R $ ln -s code.R code-1.R $ R CMD BATCH code-1.R what needs to be in code-1.R to put code-1.r into a character vector? help appreciated. regards, /ivo welch PS : I read the past R-help posts on the subject, but apparently the older suggested solutions no longer work. (commandArgs() is not the answer, either.) And I did also not see it under the FAQ in the R programming section...and may I suggest this for the faq?
On 4/2/2006 9:34 PM, ivo welch wrote:> dear R group: I have the probably fairly common problem that I would > like to have one code.R file do different things if it is invoked from > a symbolic link, which should be easy to uncover. > > $ ln -s code.R code-0.R > $ ln -s code.R code-1.R > $ R CMD BATCH code-1.R > > what needs to be in code-1.R to put code-1.r into a character vector? > help appreciated. > > regards, /ivo welch > > > PS : I read the past R-help posts on the subject, but apparently > the older suggested solutions no longer work. (commandArgs() is not > the answer, either.) And I did also not see it under the FAQ in the R > programming section...and may I suggest this for the faq?I think the answer to this is platform dependent. In Windows, the answer is: you can't. The command line gets eaten by Rcmd.exe and isn't passed to R. Duncan Murdoch
I assume you could do the analogous processing using ps on UNIX. On 4/3/06, ivo welch <ivowel at gmail.com> wrote:> hi gabor: is there a version of this for linux, too? > > regards, /iaw >
On Mon, 3 Apr 2006, ivo welch wrote:> hi gabor: thank you very much. how do you know this stuff? I just > looked at the contributors() list, and you are not on it. may I > highly suggest that a wrapper for this become part of the R base? it > should also have a link from the commandArgs() help page to whatever > this function should be called. > > regards, > > /iaw > >I am amazed at the stuff Gabor knows. After I jokingly suggested R manuals were his bedtime reading he pretty much agreed: he reads documentation and code. He is in any case an extraordinary resource, and his contributions to this list are second to none. He has my vote of appreciation. David Scott _________________________________________________________________ David Scott Department of Statistics, Tamaki Campus The University of Auckland, PB 92019 Auckland NEW ZEALAND Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000 Email: d.scott at auckland.ac.nz Graduate Officer, Department of Statistics ASC/NZSA 2006: "Statistical Connections" The joint conference of the Statistical Society of Australia Inc. and the New Zealand Statistical Association, July 3--6, 2006 in Auckland. Go to: http://www.statsnz2006.com/
> > I am amazed at the stuff Gabor knows. After I jokingly suggested R manuals > were his bedtime reading he pretty much agreed: he reads documentation and > code. > > He is in any case an extraordinary resource, and his contributions to this > list are second to none. He has my vote of appreciation. >more importantly, gabor also remembers what he reads. I usually read and then forget. gabor is great, but so are a number of other individuals here (brian ripley had to help me way too often, too). time for me to donate some more money to the R project again... regards, /iaw