1.Draw a pie chart showing the proportion of cars from the mtcars data set that have different carb values.
slices<-c(1,2,3,4,6,8)
lables<-c(mtcars$X1)
pie(slices,lables)
2.Draw a bar graph, that shows the number of each gear type in mtcars.
counts <- table(mtcars$gear)
barplot(counts, xlab="Number of Gears")
3.Next show a stacked bar graph of the number of each gear type and how they are further divded out by cyl.
counts <- table(mtcars$vs, mtcars$gear)
barplot(counts,xlab="Number of Gears", col=c("darkblue","red"),
legend = rownames(counts))
4.Draw a scatter plot showing the relationship between wt and mpg.
library(car)
scatterplot(mpg ~ wt | cyl, data=mtcars,
xlab="Weight of Car", ylab="Miles Per Gallon",
labels=row.names(mtcars))
5.Design a visualization of your choice using the data.
boxplot(mpg~cyl,data=mtcars, xlab="Number of Cylinders", ylab="Miles Per Gallon")