I try to run a sample line with iris data set gives object '...' not found error. Is there any I need to check specific in my environment?
library(plotly)
p <- plot_ly(iris, x = Petal.Length, y = Petal.Width,color = Species, mode = "markers")
Error in plot_ly(iris, x = Petal.Length, y = Petal.Width, color = Species, : object 'Petal.Length' not found
This happen to be known issue reported to plotly. To fix your example you should add tilde "~" to the data frame columns names:
library(plotly)
p <- plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width,color = ~Species, mode = "markers")
p
This should give you:
Quote from the latest plotly doc for plotly 4.0 and above:
plot_ly() now requires a formula (which is basically an expression, but with a ~ prefixed) when referencing variables. You do not have to use a formula to reference objects that exist in the namespace, but I recommend it, since it helps populate sensible axis/guide title defaults (e.g., compare the output of plot_ly(z = volcano) with plot_ly(z = ~volcano) ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With