- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Closed
Description
Would it be possible to make add_ggplot as an S3 generic?
Currently we have to resort to overwriting "+.gg"  if we want to adopt a different method based on the class of e1, e.g. GGally is a prime example of this. This allows developers to fix issues like #4304 .
The fix, as below, will be relatively simple, but the downside is that you do have to export another function.
#' @export
add_ggplot <- function(p, object, objectname) {
  UseMethod("add_ggplot")
}
#' @export
add_ggplot.ggplot <- function(p, object, objectname) {
  if (is.null(object)) return(p)
  
  p <- plot_clone(p)
  p <- ggplot_add(object, p, objectname)
  set_last_plot(p)
  p
}Metadata
Metadata
Assignees
Labels
No labels