R/proto_features.R

Defines functions proto_features

Documented in proto_features

#' @title ggplot2 layer proto extraction
#' @description Extract geom, stat and position protos from a ggplot2 layer
#' @param l ggproto
#' @return data.frame
#' @export
#' @examples
#' proto_features(ggplot2::geom_smooth())
#' proto_features(ggplot2::annotation_logticks())
#'
proto_features <- function(l) {
  a <- sapply(c("position", "geom", "stat"), function(x) {
    class(l[[x]])[1]
  })

  data.frame(t(a), stringsAsFactors = FALSE)
}

Try the ggedit package in your browser

Any scripts or data that you put into this service are public.

ggedit documentation built on July 8, 2020, 5:34 p.m.