Error with plot_ly() in R : Error in vapply(nms, function(x)

Hello,
When doing this:

p=ggplot(data,aes(x,fill=(y)))
p=p+geom_bar()
p
plot_ly(p)

I had this error message :
Error in vapply(nms, function(x) { : values must be length 1,
but FUN(X[[1]]) result is length 0

Could you please tell me how to resolve the problem?
Thank you

Could you post at least a subset of your data? It’ll help troubleshoot.

Without a fully reproducible example, it is hard to know if this will solve your problem or not, but in general if you are converting a ggplot2 plot, you should use ggplotly instead of plot_ly. plot_ly is designed for directly building a Plotly htmlwidget without help from ggplot2. So, code something like the following should work.

p=ggplot(data,aes(x,fill=(y)))
p=p+geom_bar()
p
ggplotly(p)
1 Like

Thank you verymuch, it works with ggplotly indeed !