Hi-

I used to use "<<-" to do assignment inside a class method, and
just found that now it is broken in R 2.0. For example, the
following code

-----------------------------------------------------------------------
setClass( "myclass", representation(x="numeric") )
setGeneric("incrXByOne", function(obj) standardGeneric("incrXByOne"))
setMethod( "incrXByOne", "myclass", function(obj) [EMAIL PROTECTED] <<- [EMAIL 
PROTECTED] + 1 )

incrXByOne( new("myclass") )
-----------------------------------------------------------------------

will give an error message like:

   Error in incrXByOne(new("myclass")) : Object "obj" not found
   ## R failed to trace the object back to the GlobalEnv...

It used to work under R1.7 - 1.9. I don't know whether this is a
bug or a new feature...

Anyone can recommend a workaround?

Thanks, Gang

-----------------------------
debian unstable, kernel 2.6.8

> version

platform i386-pc-linux-gnu
arch     i386
os       linux-gnu
system   i386, linux-gnu
status
major    2
minor    0.0
year     2004
month    10
day      04
language R

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to