I would like to control how code executes depending on the output type. For example
library(ggplot2)
library(plotly)
p <- ggplot(cars, aes(x=dist, y=speed)) + geom_point()
if (output_to_html)
ggplotly(p)
else
p
Is there a way to know within a RMarkdown code chunk what the output type is? I didn't find what I wanted in knitr::opts_current$get()