Load the plotly package
library(plotly)
## Loading required package: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
There is an in-built dataset called “iris” and this will be loaded into the document using the code data(iris) and then use the plot_ly() function to create the interactive graph for this presentation.
data(iris)
plot_ly(x= iris$Sepal.Width,
y= iris$Sepal.Length,
z = iris$Species,
type = "scatter3d",
mode = "markers",
color = iris$Species)
The above code creates a 3D interactive scatterplot of Sepal Width versus Sepal Length separated by Species.