data(mtcars)
attach(mtcars)
library(plotly)
Loading required package: ggplot2
Attaching package: 'ggplot2'
The following object is masked from 'mtcars':
mpg
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
library(ggplot2)
p<- mtcars%>%
ggplot(aes(x=hp, y=mpg,frame = cyl,color =wt,size=qsec)) +
labs(x="Horse Power", y = "Miles Per Gallon",
caption = "Mtcars dataset",color = 'Weight (1000lbs)',size = "1/4 mile time")+
xlim(45,340)+
ylim(9.5,34.5)+
geom_point()
ggplotly(p)
[1] "mpg" "cyl" "disp" "hp" "drat" "wt" "qsec" "vs" "am" "gear"
[11] "carb"