Developing Data Products Project 2 Presentation: Analysis of MPG in cars vs several expalantory variables

CC
June 29, 2020

Data

The data used in this Shiny application is the mtcars dataset.

library(tidyverse)
head(mtcars)
                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

Choice of variable for linear regression

Our response is the mpg of a given vehicle. Our application gives the choice of response variable, from which a linear regerssion is generated to estimate the mpg of other cars. One example is to model mpg based on the number of cylinders in the engine.

head(mtcars %>% select(mpg, cyl))
                   mpg cyl
Mazda RX4         21.0   6
Mazda RX4 Wag     21.0   6
Datsun 710        22.8   4
Hornet 4 Drive    21.4   6
Hornet Sportabout 18.7   8
Valiant           18.1   6

Example plot

Our application visualizes this data with a plot: plot of chunk unnamed-chunk-3

Data output

Finally, for convenience, our application will display the data output in tabular form next to the choice of explanatory variable.