print.ggplot
Print by drawing a plot inside a function or for loop and then convert them with ggplotly.
colours <- list(~class, ~drv, ~fl) p <- # Doesn't seem to do anything! for (colour in colours) { ggplot(mpg, aes_(~ displ, ~ hwy, colour = colour)) + geom_point() }
plotly::ggplotly(p)
## Error in UseMethod("api_create"): no applicable method for 'api_create' applied to an object of class "shiny.tag"
colours <- list(~class, ~drv, ~fl) p <- # Works when we explicitly print the plots for (colour in colours) { print(ggplot(mpg, aes_(~ displ, ~ hwy, colour = colour)) + geom_point()) }
plotly::ggplotly(p)
## Error in UseMethod("api_create"): no applicable method for 'api_create' applied to an object of class "shiny.tag"