Average miles per gallon

rhao22
06.10.2015

The application

This application calculates the average miles per gallon of cars depending on:

  • The number of cylinders the car has, it can be selected from 4 to 8
  • The number of forward gears, it can be selected from 3 to 5
  • If the transmission is manual or automatic, this can be checked

Calculation

Here is a calculation example frc cars with:

  • 4 cylinders
  • 4 forward gears
  • A manual transmission
  subset1 <- mtcars[which(mtcars$cyl==4),]
  subset2 <- subset1[which(subset1$gear==4),]
  subset3 <- subset2[which(subset2$am==1),]
  MeanMPG <- mean(subset3$mpg)
  MeanMPG
[1] 28.03333

MPG Plot

A graph is shown displaying the miles per gallon depending on the weight of the cars. With the same parameter as in the previous slide:

plot of chunk unnamed-chunk-2

Conclusion

This application gives an idea of the miles per gallon average of cars having a specific number of cylinders, forward gears and being automatic or manual.