Tarun Kaushik
December 21, 2014
Car milage calculator is a simple app. As evident from the name, it calculated, or rather estimates the milage of a car when some values are provided. Following are the details about car which the user has to enter.
Based on the mtcars dataset provided in R a linear model was fit on miles per gallon, with the following model summary:
Equation
\( mpg=17.12752 \) \( -0.05103*cyl \) \( -0.01328*hp \) \( -2.71336*wt/1000 \) \( +0.63603*iqsec \) \( +0.18232*am \) \( +2.66026*vs \) \( +0.81521*gear \) \( -0.55570*carb \)
data(mtcars)
library(xtable)
names <- names(mtcars)
names <- setdiff(names,c("drat","disp"))
mtcars <- mtcars[,names]
fit <- lm(mpg~.,data=mtcars)
k <- xtable(summary(fit)$coefficients)
print(k, type="html")
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | 17.13 | 16.50 | 1.04 | 0.31 |
| cyl | -0.05 | 0.95 | -0.05 | 0.96 |
| hp | -0.01 | 0.02 | -0.73 | 0.47 |
| wt | -2.71 | 1.17 | -2.32 | 0.03 |
| qsec | 0.64 | 0.68 | 0.93 | 0.36 |
| vs | 0.18 | 2.04 | 0.09 | 0.93 |
| am | 2.66 | 1.98 | 1.34 | 0.19 |
| gear | 0.82 | 1.45 | 0.56 | 0.58 |
| carb | -0.56 | 0.59 | -0.95 | 0.35 |
ui.R
server.R
The app diplays all the values entered by the user, calculates estimated miles per gallon of the car and displays it along with the density graph like the one shwn below.