introduction

data set over view

# 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

Visual Analysis Questions

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"))

histogram of car weights

hist(mtcars$wt, main="Distribution of Car Weights", 
     xlab="Weight (1000 lbs)", col="lightblue", breaks=10)

bar plot showing the count of cars by gear type.

barplot(table(mtcars$gear), main="Number of Cars by Gear Type",
        xlab="Gears", ylab="Count", col=c("red","green","blue"))

pair plot for mpg, hp, and wt to observe relationship

pairs(~mpg + hp + wt, data=mtcars, main="Pair Plot of mpg, hp, and wt")