[R] Command line parameters to a script

Morten Sickel Morten.Sickel at nrpa.no
Mon Dec 16 13:40:04 CET 2002


I am using R quite a lot for reading data from a db and plotting them. I
often have to make different language versions of my plots, i.e. in
Norwegian and English. In stead of making and maintaining two different
versions of the script files, I am looking for a variable within the script,
e.g.:

  if (lang=='N') {
	"Utslipp (TBq/år)"->yrtext } else {
	"Releases (TBq/year)"->yrtext }

Then I can set lang to N to get the Norwegian version or to something else
to get the english labels. To avoid a crash when I have not set lang, I also
need

  if (length(objects(pattern='lang'))==0) 'E'-> lang

early in the script. 

I would like to know if there are any other possibilities for sending
'command line parameters' to a script? Although the present way of doing it
works, it feels like a kludge. If not, are there any other way to check for
the existence of an object with a give name?

Morten

-- 
Morten Sickel
Norwegian Radiation Protection Authority
http://www.nrpa.no




More information about the R-help mailing list