this may be a fairly straight forward question.
I am wanting to test if an object is a plotly object or not. I would ideally be testing a ggplotly()
object.
Is there any simple way to do this? I can't seem to find a function like;
> x <- ggplot()
>
> is.ggplot(x)
[1] TRUE
If anyone could point me in the right dirction that would be greatly appreciated!
class(x)
returns
[1] "plotly" "htmlwidget"
where x
is created using ggplotly
.
So how about something like:
"plotly" %in% class(x)
[1] TRUE
You could make it into a function is.plotly
:
is.plotly <- function(x) {
"plotly" %in% class(x)
}