r - Error in ggplotly: attempt to apply non-function -
i produce interactive ggplot graph using function ggplotly
here 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, error shows after last codeggplotly(p)
:
error in gg2list(p, width = width, height = height, tooltip = tooltip, : attempt apply non-function
any idea fix problem?
use plotly_build
instead. following code works on pc:
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 <- plotly_build(p) print(gg)
Comments
Post a Comment