Re: [Rd] Calling default method for primitive functions

2009-11-23 Thread Hadley Wickham
Perfect - thanks! Hadley On Mon, Nov 23, 2009 at 5:22 PM, Gabor Grothendieck wrote: > See ?.subset > > On Mon, Nov 23, 2009 at 4:00 PM, Hadley Wickham wrote: >> Hi all, >> >> How can I call the default method of a S3 object defined by a >> primitive method?   i.e. in the following example, how d

Re: [Rd] Calling default method for primitive functions

2009-11-23 Thread Gabor Grothendieck
See ?.subset On Mon, Nov 23, 2009 at 4:00 PM, Hadley Wickham wrote: > Hi all, > > How can I call the default method of a S3 object defined by a > primitive method?   i.e. in the following example, how do I call the > default [ method instead of the one I defined for the class. > > new_a <- functi

Re: [Rd] Calling default method for primitive functions

2009-11-23 Thread Hadley Wickham
>> new_a <- function(x) structure(x, class = "a") >> >> a <- new_a(1:5) >> >> "[.a" <- function(x, i, j, ...) { >>  new_a(x[, j, ]) > > What about > new_a(unclass(x)[, j,]) That's what I'm currently using, but I'm concerned about the performance implications - won't that create a copy of x? Hadle

Re: [Rd] Calling default method for primitive functions

2009-11-23 Thread Simon Urbanek
On Nov 23, 2009, at 16:00 , Hadley Wickham wrote: Hi all, How can I call the default method of a S3 object defined by a primitive method? i.e. in the following example, how do I call the default [ method instead of the one I defined for the class. new_a <- function(x) structure(x, class = "

[Rd] Calling default method for primitive functions

2009-11-23 Thread Hadley Wickham
Hi all, How can I call the default method of a S3 object defined by a primitive method? i.e. in the following example, how do I call the default [ method instead of the one I defined for the class. new_a <- function(x) structure(x, class = "a") a <- new_a(1:5) "[.a" <- function(x, i, j, ...)