This is my first assignment for R on Graphic Design. There are 5 questions in the assignment.
##Question 1
table(mtcars$carb)
##
## 1 2 3 4 6 8
## 7 10 3 10 1 1
slices<-c(1,2,3,4,6,8)
fre<-c(7,10,3,10,1,1)
pie(slices,labels=fre,main = "pie of mtcars cars")
## Quesion 2
counts<-table(mtcars$gear)
barplot(counts,xlab = "Number of Gears")
##Question 3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.4.3
mtcarsgear<-factor(mtcars$gear)
mtcars$cyl<- factor(mtcars$cyl)
p <- ggplot(data = mtcars, aes(x=gear, fill=cyl) ) + geom_bar()
p <- p + xlab("Gears") + ggtitle("Cyl")
##Question 4
x<-mtcars$wt
y<-mtcars$mpg
plot(x,y)
##Question 5
table(mtcars$cyl)
##
## 4 6 8
## 11 7 14
slices<-c(4,6,8)
fre<-c(11,7,4)
pie(slices,labels = fre)
##knitr::include_graphics("Users/fzhu/Desktop/Feng/Data Visualization/graph.jpg")
I am having trouble attaching the picture in Rmarkdown.