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.

Reply via email to