[R] Scope problems - passing an argument from one function to another (LME) within

Derek Eder Derek.Eder at neuro.gu.se
Fri Sep 6 14:58:33 CEST 2002


I am having trouble understanding what must be a quite simple rule of scope.

In the code example below, the argument to the main function, my.subset, would like to be passed to the function LME.  This does not happen however.  Curiously, the other argument (my.data) is passed to LME.

This problem goes away with this:  assign("my.subset", my.subset, env = sys.frame()).

It works, but it doesn't feel right.  How can I get LME to join the scope of the main function?


Thank you,

Derek Eder

   


my.function_function(my.data,my.subset="NORM")
{

##  call to function LME.  Problem:  the variable my.subset is not seen by LME  ##
  
# assign("my.subset", my.subset, env = sys.frame())     Now it works! #

my.result_lme( X ~ Y, random=~1|Z, data=my.data, subset= W==my.subset)

}

Derek N. Eder
Göteborgs Universitet
Institutionen för klinisk neurovetenskap
Klinisk Neurofysiologi
Sahlgrenska universitetssjukhuset SS/SU
Blå straket 7, vån 3
SE 413 45  Göteborg
Sverige
Tlf. +46 (031) 34  2-6139  (office)
Tlf. +46 (031) 34 2-1283  (laboratory)
Tlf. +46 0709 / 7 2-1283 (mobil)
Fax. +46 (031) 82 81 63 
derek.eder at neuro.gu.se


Gothenburg University
Institute of Clinical Neuroscience,
Department of Clinical Neurophysiology
Salhgrenska Hospital  SU/SS
SE 413 45  Göteborg
Sweden


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list