This is the week 3 assignment of the Developing Data Products in Coursera. Here we use plotly to make our ggplot output becomes interactive. We will use the mtcars dataset.
p<-ggplot(data=mtcars, aes(y=mpg, x=hp))+geom_point(aes(color=as.factor(mtcars$am)))+geom_smooth()
p
## `geom_smooth()` using method = 'loess'
gg<-ggplotly(p)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
## `geom_smooth()` using method = 'loess'
gg