R Markdown

This is the output for assignment -I of Data Visualization Class.

data(mtcars) #Load the datset#
  1. Draw a pie chart showing the proportion of cars from the mtcars data set that have different carb values.
  2. Draw a bar graph, that shows the number of each gear type in mtcars. Image output 1
  3. Next show a stacked bar graph of the number of each gear type and how they are further divded out by cyl.
Image output 2

Image output 2

  1. Draw a scatter plot showing the relationship between wt and mpg.
  2. Design a visualization of your choice using the data.
Image output 3

Image output 3

Including Plots

Plots for mtcars

barplot(mtcars$gear) #bar graph that shows the number of each gear type#

slices <- c(7, 10, 3, 10, 1, 1)
lbls <- c("1 carb", "2 carb", "3 carb", "4 carb", "6 carb", "8 carb")
pie(slices, labels = lbls, main = "Pie Chart for carb distribution") #pie chart showing the proportion of cars from the mtcars data set that have different carb values#

counts <- table(mtcars$cyl, mtcars$gear)
barplot(counts, main = "Car Distribution by Gears and Cylinder", xlab = "Number of Gears", col = c("blue", "red", "green"), legend = rownames(counts)) #stacked bar graph of the number of each gear type and how they are further divded out by cyl#

plot(mtcars$wt, mtcars$mpg) #scatter plot showing the relationship between wt and mpg#

hist(mtcars$mpg, col=c("grey"), main="No. of Cars by Mileage") #histogram showing the distribution of mpg#

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.