In further offline discussion with the poster it was explained that the purpose of this is to display the icon object and not to return an instantiatedProtoMethod which was what the code was attempting to do. That is in proto, g$icon is not the icon object. It is the icon method instantiated with the g object, essentially a currying operation in which the object is plugged into the first arguement of icon and the resulting function (no longer a method since its now been instantiated) returned. To get what the poster desires, namely the icon object itself, one would do this instead of g$icon:
with(g, icon) On Thu, Oct 8, 2009 at 7:44 PM, Gabor Grothendieck <ggrothendi...@gmail.com> wrote: > 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.aug...@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@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. >> > ______________________________________________ R-help@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.