How to determine the geom type of each layer of a ggplot2 object?
问题 As part of an effort to remove a specific geom from a plot I've already created (SO link here), I'd like to dynamically determine the geom type of each layer of a ggplot2 object. Assuming I don't know the order in which I added layers, is there a way to dynamically find layers with a specific geom? If I print out the layers like I do below I can see that the layers are stored in a list, but I can't seem to access the geom type. library(ggplot2) dat <- data.frame(x=1:3, y=1:3, ymin=0:2, ymax=2