From simon.urbanek at r-project.org  Mon Nov 23 23:30:57 2009
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon, 23 Nov 2009 17:30:57 -0500
Subject: [Rd] Calling default method for primitive functions
In-Reply-To: <f8e6ff050911231300p162230d7pad4875528b5e96ff@mail.gmail.com>
References: <f8e6ff050911231300p162230d7pad4875528b5e96ff@mail.gmail.com>
Message-ID: <7C7F838E-D1E3-491A-AF49-B28ED108BC82@r-project.org>


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 = "a")
>
> a <- new_a(1:5)
>
> "[.a" <- function(x, i, j, ...) {
>  new_a(x[, j, ])

What about
new_a(unclass(x)[, j,])

Cheers,
Simon


> }
>
> a[, 5]
>
> Thanks,
>
> Hadley
>
> -- 
> http://had.co.nz/
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] Calling default method for primitive functions
Simon Urbanek