You are on page 1of 10

attach(mtcars)

boxplot(mpg)

boxplot(mpg,horizontal = TRUE)
summary(mpg)

## Min. 1st Qu. Median Mean 3rd Qu. Max.


## 10.40 15.43 19.20 20.09 22.80 33.90

boxplot(mpg,horizontal = TRUE,col="green",border = "red")


boxplot(mpg,horizontal = TRUE,col="green",border = "red",main="Miles per
Gallon")
boxplot(mpg,horizontal = TRUE,col="green",border = "red",main="Miles per
Gallon",xlab="mileage")

boxplot(mpg,horizontal = TRUE,col="green",border = "red",main="Miles per


Gallon",xlab="mileage",ylab="Number of Cars")
boxplot(mpg~cyl,horizontal = TRUE,col="green",border = "red",main="Miles per
Gallon",xlab="mileage",ylab="Number of Cars")
boxplot(mpg~am,horizontal = TRUE,col="green",border = "red",main="Miles per
Gallon",xlab="mileage",ylab="Number of Cars")

cor(hp,mpg)

## [1] -0.7761684

plot(hp,mpg)
plot(hp,mpg,col=c("red","blue"),lwd=4)

plot(hp,mpg,col=c("red","blue"),lwd=3)
plot(hp,mpg,col=c("red","blue"),lwd=2)

cor(disp,mpg)
## [1] -0.8475514

plot(disp,mpg)

plot(disp,mpg,col=c("red","blue"),lwd=4)
mean(mpg);mean(hp);mean(disp)

## [1] 20.09062

## [1] 146.6875

## [1] 230.7219

median(mpg);median(hp);median(disp)

## [1] 19.2

## [1] 123

## [1] 196.3

mode(mpg);mode(hp);mode(disp)

## [1] "numeric"

## [1] "numeric"

## [1] "numeric"

You might also like