In this Project I have developed a shiny web application which can be found here:
https://gaurabkundu1.shinyapps.io/ShinyApp_DDP/
The Github Repo contains the Code:
https://github.com/GaurabKundu1/Developing-Data-Products-Course-Project
2023-01-03
In this Project I have developed a shiny web application which can be found here:
https://gaurabkundu1.shinyapps.io/ShinyApp_DDP/
The Github Repo contains the Code:
https://github.com/GaurabKundu1/Developing-Data-Products-Course-Project
The data was extracted from the 1974 Motor Trend US magazine, and comprises fuel consumption and 10 aspects of automobile design and performance for 32 automobiles (1973-74 models). ### Source Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391-411.
## 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
A data frame with 32 observations on 11 variables.
| Index | Field | Detail |
|---|---|---|
| [, 1] | mpg | Miles/(US) gallon |
| [, 2] | cyl | Number of cylinders |
| [, 3] | disp | Displacement (cu.in.) |
| [, 4] | hp | Gross horsepower |
| [, 5] | drat | Rear axle ratio |
| [, 6] | wt | Weight (lb/1000) |
| [, 7] | qsec | 1/4 mile time |
| [, 8] | vs | V/S |
| [, 9] | am | Transmission (0 = automatic, 1 = manual) |
| [,10] | gear | Number of forward gears |
| [,11] | carb | Number of carburetors |
library(shiny)
shinyUI(
navbarPage("Shiny Application",
tabPanel("Analysis",
fluidPage(
titlePanel("The relationship between variables and miles per gallon (MPG)"),
sidebarLayout(
sidebarPanel(
selectInput("variable", "Variable:",
c("Number of cylinders" = "cyl",
"Displacement (cu.in.)" = "disp",
"Gross horsepower" = "hp",
"Rear axle ratio" = "drat",
"Weight (lb/1000)" = "wt",
"1/4 mile time" = "qsec",
"V/S" = "vs",
"Transmission" = "am",
"Number of forward gears" = "gear",
"Number of carburetors" = "carb"
)),
checkboxInput("outliers", "Show BoxPlot's outliers", FALSE)
),
mainPanel(
h3(textOutput("caption")),
tabsetPanel(type = "tabs",
tabPanel("BoxPlot", plotOutput("mpgBoxPlot")),
tabPanel("Regression model",
plotOutput("mpgPlot"),
verbatimTextOutput("fit")
)
)
)
)
)
),
tabPanel("About the Data Set",
h3("Regression Models Course Project (from Coursera)"),
helpText("You work for Motor Trend, a magazine about the automobile industry Looking at a data set of a collection of cars, they are interested in exploring the relationship",
"between a set of variables and miles per gallon (MPG) (outcome). They are particularly interested in the following two questions: Is an automatic or manual transmission better for MPG. Quantify the MPG difference between automatic and manual transmissions"),
h3("Important"),
p("A data frame with 32 observations on 11 variables."),
a("https://class.coursera.org/regmods-008")
),
tabPanel("More Data Detail",
h2("Motor Trend Car Road Tests"),
hr(),
h3("Description"),
helpText("The data was extracted from the 1974 Motor Trend US magazine,",
" and comprises fuel consumption and 10 aspects of automobile design and performance",
" for 32 automobiles (1973-74 models)."),
h3("Format"),
p("A data frame with 32 observations on 11 variables."),
p(" [, 1] mpg Miles/(US) gallon"),
p(" [, 2] cyl Number of cylinders"),
p(" [, 3] disp Displacement (cu.in.)"),
p(" [, 4] hp Gross horsepower"),
p(" [, 5] drat Rear axle ratio"),
p(" [, 6] wt Weight (lb/1000)"),
p(" [, 7] qsec 1/4 mile time"),
p(" [, 8] vs V/S"),
p(" [, 9] am Transmission (0 = automatic, 1 = manual)"),
p(" [,10] gear Number of forward gears"),
p(" [,11] carb Number of carburetors"),
h3("Source"),
p("Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391-411.")
),
tabPanel("Go back to my Github repository",
a("https://github.com/GaurabKundu1/Developing-Data-Products-Course-Project"),
hr(),
h4("I hope you like the Shiny App"),
h4("The name of the repository is Developing Data Products Course Project")
)
)
)
A data frame with 32 observations on 11 variables.
https://class.coursera.org/regmods-008A data frame with 32 observations on 11 variables.
[, 1] mpg Miles/(US) gallon
[, 2] cyl Number of cylinders
[, 3] disp Displacement (cu.in.)
[, 4] hp Gross horsepower
[, 5] drat Rear axle ratio
[, 6] wt Weight (lb/1000)
[, 7] qsec 1/4 mile time
[, 8] vs V/S
[, 9] am Transmission (0 = automatic, 1 = manual)
[,10] gear Number of forward gears
[,11] carb Number of carburetors
Henderson and Velleman (1981), Building multiple regression models interactively. Biometrics, 37, 391-411.
library(shiny)
library(datasets)
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
shinyServer(function(input, output) {
formulaText <- reactive({
paste("mpg ~", input$variable)
})
formulaTextPoint <- reactive({
paste("mpg ~", "as.integer(", input$variable, ")")
})
fit <- reactive({
lm(as.formula(formulaTextPoint()), data=mpgData)
})
output$caption <- renderText({
formulaText()
})
output$mpgBoxPlot <- renderPlot({
boxplot(as.formula(formulaText()),
data = mpgData,
outline = input$outliers)
})
output$fit <- renderPrint({
summary(fit())
})
output$mpgPlot <- renderPlot({
with(mpgData, {
plot(as.formula(formulaTextPoint()))
abline(fit(), col=2)
})
})
})