2017/5/23

Purpose of the Presentation

This presentation describes a Shiny application created for PA for Johns Hopkins Coursera Data Science Unit 9, "Developing Data Products.

The application uses mtcars data to help user to do quick exploratory analysis to test how selected variable infuluences mpg(Miles Par Gallons) of vehicle.

The application is published at the Shiny Server(https://takashisendo.shinyapps.io/JH_Unit9_PA4/).

Overview of the Application

The application has the following features.

  • Viewer can select variable by Radio Button
  • Plot is included to do scatter plot of mpg on the variable
  • Create a linear regression model for mpg on the selected variable
  • Plot the linear model if the viewer wishes

How to construct radio button

The following codes are used for selecting variable at ui and server.

## selecting input at ui
radioButtons("x1", "Choose x variable for a linear model:",
                             c("# Cylinder" = "cyl",
                               "Disp" = "disp",
                               "HP" = "hp",
                               "drat" = "drat",
                               "weight"="wt",
                               "qsec"="qsec"))
## using the selected variable at server
a <- switch(input$x1,
                    "cyl"=mtcars$cyl,
                    "disp"=mtcars$disp,
                    "hp"=mtcars$hp,
                    "drat"=mtcars$drat,
                    "wt"=mtcars$wt,
                    "qsec"=mtcars$qsec)
        model <- lm(mtcars$mpg~a)

Example of Output to be seen at Shiny Server