Peer-graded Assignment:

Course Project: Shiny Application and Reproducible Pitch

A Johnson

September 22, 2019

Background

The associated shiny app uses the “mtcars” dataset available in R to predict a vehicle’s horsepower given the number of miles per gallon (MPG), approximate displacement of the car (in cu. in.), and the approximate weight of the car (in 1,000 lbs), stratified by the number of cylinders (4, 6, or 8).

    data(mtcars)    
    covars = c("hp", "mpg", "disp", "wt")

    for (i in covars) {
        print(i)
        print(summary(mtcars[[i]]))
        #writeLines("\n") #writes empty line to separate outputs
    }
## [1] "hp"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    52.0    96.5   123.0   146.7   180.0   335.0 
## [1] "mpg"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   10.40   15.43   19.20   20.09   22.80   33.90 
## [1] "disp"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    71.1   120.8   196.3   230.7   326.0   472.0 
## [1] "wt"
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.513   2.581   3.325   3.217   3.610   5.424

Varying Factors

The user can modify each of the following factors by adjusting the associated slider:

- Miles per gallon (min: 10, max: 35)
- Displacement (min: 70, max: 500, in cu. in.)
- Weight (min: 1, max: 6, in 1,000 lbs)

The user can select to view each model specific to the number of cylinders on the vehicle (4, 6, or 8) be checking/unchecking each box below the sliders (e.g. “Show/Hide Model for 4-Cylinder Vehicles”).

Plot and Predicted Outcome

The plot displays a color-coded dot for each type of vehicle that corresponds to the user-specified MPG and associated horsepower, given the user-specified displacement and weight of the car. If any of the “show/hide” checkboxes are selected, the plot also displays the best fitting line from the linear regression model for the associated type of vehicle.

The predicted horsepower for each type of vehicle are also displayed as text below the plot.

Viewing the App in Action:

The application can be viewed here: https://ajohns34.shinyapps.io/Course_Project/