[R] proto and get()
baptiste auguie
baptiste.auguie at googlemail.com
Thu Oct 8 19:02:41 CEST 2009
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
More information about the R-help
mailing list