From plummer@iarc.fr  Thu Jun 18 08:44:21 1998
From: plummer@iarc.fr (Martyn Plummer)
Date: Thu, 18 Jun 1998 09:44:21 +0200
Subject: bug in functions of form "mcpar<-"
References: <XFMail.980617162415.plummer@iarc.fr> <x2n2bcnd3u.fsf@blueberry.kubism.ku.dk>
Message-ID: <3588C555.288AEF94@iarc.fr>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


bug in functions of form "mcpar<-"
Martyn Plummer