[R] proto and get()

Gabor Grothendieck ggrothendieck at gmail.com
Fri Oct 9 01:44:42 CEST 2009


This may be a bug in objects of class "instantiatedProtoMethod".   I
tried it with the devel version of proto and got no error so you could
try that.  I will send it to you offline for your try.

On Thu, Oct 8, 2009 at 1:02 PM, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Dear all,
>
> In mucking around with ggplot2, I've hit the following snag,
>
> library(ggplot2)
>
> # this returns a grob, OK
> GeomAbline$icon()
> # lines[GRID.lines.9]
>
> # this returns the function icon, OK
> GeomAbline$icon
> # proto method (instantiated with ): function (.)
> # linesGrob(c(0, 1), c(0.2, 0.8))
> # <environment: 0x13e6800>
>
> Now I want to wrap this in a function,
>
> getIcon <- function(geom){
>  st <- paste("Geom", firstUpper(geom), sep="")
>
>  g <- get(st, 2)
>
>  g$icon()
> }
>
> getIcon("abline") # still OK
> # lines[GRID.lines.10]
>
> but ...
>
> getIcon <- function(geom){
>  st <- paste("Geom", firstUpper(geom), sep="")
>
>  g <- get(st, 2)
>
>  g$icon
> }
> getIcon("abline")
> # proto method (instantiated with ):
> # Error in get("icon", env = g, inherits = TRUE) : object 'g' not found
>
> So, it seems that I'm being too naive about using get on a proto
> object or something along those lines.
>
> I'd be grateful if proto experts could help me extract the icon
> function from this object.
>
> Best regards,
>
> baptiste
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list