I would like to produce interactive ggplot graph using the function ggplotly
Here is my code:
set.seed(100)
d <- diamonds[sample(nrow(diamonds),1000),]
p <- ggplot(data = d,aes(x=carat,y=price))+
geom_point(aes(text=paste("Clarity:",clarity)),size = 4)+
geom_smooth(aes(color = cut,fill=cut))+facet_wrap(~cut)
gg <- ggplotly(p)
However, the error shows up as after the last codeggplotly(p):
Error in gg2list(p, width = width, height = height, tooltip = tooltip, : attempt to apply non-function
Any idea to fix the problem?