bug in functions of form "mcpar<-"
Martyn Plummer
plummer@iarc.fr
Thu, 18 Jun 1998 09:44:21 +0200
Peter Dalgaard BSA wrote:
> Hmm. We had some pretty antisocial consequences from *not* using the
> value= form with John Chambers' [<-.data.frame code, which assumes
> that it is used that way in order to see whether i,j, or both are
> absent.
>
> So Splus is using value= on indexing operations only?
Looks like it. As I said, my other example works in S-PLUS, but try
doing
the same thing with an assignment on an index and you get an error:
(This examples is obviously silly in order to distinguish it from the
default
indexing function).
S> "[<-.foo" <-
function(x,i,value){y<-unclass(x);y[i]<-value+1;class(y)<-"foo";y}
S> x <- 1:10
S> class(x) <- "foo"
S> x[1]<-100
S> x
[1] 101 2 3 4 5 6 7 8 9 10
attr(, "class"):
[1] "foo"
S> "[<-.foo" <-
function(x,i,bar){y<-unclass(x);y[i]<-bar+1;class(y)<-"foo";y}
S> x[1]<-200
Error in call to [<-.foo(): Argument value= not matched
Dumped
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._