11/27/2020

STEPS FOR USERS

Put the details like weight(wt),qsec,transmission mode(am) and then click submit. In the above box you will get the value for expected miles/gallon value

Mtcars Data Set Prediction Model predicting miles per gallon User have to enter the weight,qsec and the transmission mode for calculating answer

UI

library(shiny)
library(shinyWidgets)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
    # Application title
    titlePanel("Mtcars Data Set Prediction Model predicting miles per gallon
               User have to enter the weight,qsec and the transmission mode for calculating answer"),
     setBackgroundColor(color=c("#F7FBFF","#2171B5"),gradient="linear",direction="bottom"),
    # Sidebar with a slider input for number of bins
    sidebarLayout(
        sidebarPanel(
            textOutput("mpg1")
        ),
        # Show a plot of the generated distribution
        mainPanel(    numericInput("wt","Enter the weight",value=0),numericInput("qsec","Enter the qsec",value=0),numericInput("am","Enter 0 for automatic and 1 for manual",value=0),
            submitButton("Submit"),
        )
    )
))

SERVER END CODE

library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
    data(mtcars)
    model1<-lm(mpg~wt+qsec+am,data=mtcars)
    t <- reactive({
               wt1<-input$wt
               qsec1<-input$qsec
               am1<-input$am
               predict(model1,newdata=data.frame(wt=wt1,qsec=qsec1,am=am1))
    })
    output$mpg1<-renderText({
        t()
    })
})

Url ShinyAPP