R Markdown

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.1

Problem 1

ggplot(data=mtcars,aes(x=factor(1),fill=factor(carb)))+ylab("Cars by Carb")+xlab("")+geom_bar(width=1)+coord_polar(theta="y")

Problem 2

ggplot(data=mtcars, aes(x=gear)) + geom_bar(stat="count")

Problem 3

ggplot(mtcars, aes(x = factor(cyl), fill = factor(gear))) + xlab("Cyl") + ylab("Gear") + geom_bar(color="Blue")

Problem 4

ggplot(mtcars, aes(x = wt, y = mpg)) + xlab("weight") + ylab("mpg") + geom_point() + geom_line() + ggtitle("Relationship between 'wt' and 'mpg'") + stat_smooth(method = "loess", formula = y ~ x, size = 1, col = "Green")

Problem 5

ggplot(mtcars, aes(x = hp, y = mpg))+ geom_point(aes(shape=factor(cyl), color=factor(cyl))) + scale_shape_discrete(name="Cylinders") + scale_color_discrete(name="Cylinders")

# This plot shows car types based on the cylinder types. Types can be identified easily based on the shape of the icon displayed in the plot. Additionally it also displays increase in Horse Power reduces fuel economy (mpg)