library(ggplot2)
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.4.3
summary(mpg)
## manufacturer model displ year
## Length:234 Length:234 Min. :1.600 Min. :1999
## Class :character Class :character 1st Qu.:2.400 1st Qu.:1999
## Mode :character Mode :character Median :3.300 Median :2004
## Mean :3.472 Mean :2004
## 3rd Qu.:4.600 3rd Qu.:2008
## Max. :7.000 Max. :2008
## cyl trans drv cty
## Min. :4.000 Length:234 Length:234 Min. : 9.00
## 1st Qu.:4.000 Class :character Class :character 1st Qu.:14.00
## Median :6.000 Mode :character Mode :character Median :17.00
## Mean :5.889 Mean :16.86
## 3rd Qu.:8.000 3rd Qu.:19.00
## Max. :8.000 Max. :35.00
## hwy fl class
## Min. :12.00 Length:234 Length:234
## 1st Qu.:18.00 Class :character Class :character
## Median :24.00 Mode :character Mode :character
## Mean :23.44
## 3rd Qu.:27.00
## Max. :44.00
Visual 1:
ggplot(mpg, aes(class)) + geom_bar(aes(fill= trans))
Visual 2:
ggplot(mpg, aes( mpg$manufacturer,mpg$hwy)) + geom_boxplot()+coord_flip()+labs(
y = "Highway Fuel Efficiency (miles/gallon)",
x = "Vehicle Manufacturer")
Visual 3:
ggplot(diamonds, aes(x=price,color=cut,fill=cut)) + geom_density(aes(fill=factor(cut)), alpha=0.2) +theme_economist() + scale_colour_economist() +labs(title="Diamond Price Density ", x="Diamond Price(USD)", y="Density")
Visual 4:
ggplot(iris, aes(iris$Sepal.Length,iris$Petal.Length)) + geom_point() + labs(y = "Iris Sepal Length",
x = "Iris Petal Length", title = "Relationship between Petal and Sepal Length") + geom_smooth(method=lm)
Visual 5:
ggplot(iris, aes(iris$Sepal.Length,iris$Petal.Length, color =iris$Species)) + geom_point() + labs(y = "Iris Sepal Length",
x = "Iris Petal Length", title = "Relationship between Petal and Sepal Length") + geom_smooth(method=lm)