Created
May 22, 2011 13:49
-
-
Save kohske/985482 to your computer and use it in GitHub Desktop.
ggplot return object with stat and geom name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g <- ggplot(mtcars, aes(cyl, mpg)) + geom_point() + stat_summary(fun.y=mean, geom="line") | |
d <- print(g) | |
## look up data from "stat" | |
get_data_from_stat <- function(gobj, stat) Find(function(x)attr(x, "stat")==stat, gobj$data) | |
## look up data from "geom" | |
get_data_from_geom <- function(gobj, geom) Find(function(x)attr(x, "geom")==geom, gobj$data) | |
get_data_from_stat(d, "summary") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment