R - object error object ... not found

I am trying to run a sample string with iris iris set if the object "..." is not found. Do I need to check for specifics 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 = Views :: object 'Petal.Length' not found

+4
source share
1 answer

This is a known issue that is reported graphically . To fix your example, you must add the tilde "~" to the column names of the data frame:

library(plotly)
p <- plot_ly(iris, x = ~Petal.Length, y = ~Petal.Width,color = ~Species, mode = "markers")
p

This should give you:
plot_ly graph of the built-in aperture set

Quote from the last story document for plotly 4.0 and higher:

plot_ly() ( , ~ ) . , , , / (, plot_ly (z = volcano) plot_ly (z = ~ )).

+4

Source: https://habr.com/ru/post/1657043/


All Articles