#introduction
# mean of mtcars data set
mean(mtcars$mpg)
## [1] 20.09062
# median of mtcars data set
median(mtcars$hp)
## [1] 123
# sum of mtcars data set
sum(mtcars$cyl == 8)
## [1] 14
# range of mtcars data set
range(mtcars$wt)
## [1] 1.513 5.424
sd(mtcars$mpg)
## [1] 6.026948
plot(mtcars$hp, mtcars$mpg, main="Horsepower vs MPG",
xlab="Horsepower", ylab="Miles per Gallon", col="blue", pch=19)
## box plot of mpg grouped by the number of cylinders
boxplot(mpg ~ cyl, data=mtcars, main="MPG by Cylinder Count",
xlab="Cylinders", ylab="Miles per Gallon", col=c("orange","green","purple"))
hist(mtcars$wt, main="Distribution of Car Weights",
xlab="Weight (1000 lbs)", col="lightblue", breaks=10)
barplot(table(mtcars$gear), main="Number of Cars by Gear Type",
xlab="Gears", ylab="Count", col=c("red","green","blue"))