specifically, imagine we have:

     fooStack <- list()
     for ( i in 1:5 )
         fooStack[[i]] <- list()

   and we have a function:

     fooModifier <- function( foo ) {

     foo$bar <- "bar"

     }

   then, if we invoke fooModifier, i.e.:

     fooModifier( fooStack[[ 1 ]] )

   the $bar elt is only set in the scope of the function, and if we use the
   "<<-" modifier in fooModifier, R will throw an error b/c it can't find the
   "foo" object.  I have to say that for someone coming from languages that
   have pointers and/or references, it's really frustrating that R fails to
   allow one to have direct access to the objects' memory space.
   Onyway, one workaround would be to pass in the whole fooStack object and the
   index of the elt that you want to modify to the fooModifier fn, but I'd
   rather not have to pass the whole thing in.
   Any suggestions?
   Thanks!
   Peter Waltman
______________________________________________
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.

Reply via email to