library(shiny)
ui
<- fluidPage(
pageWithSidebar(
headerPanel("HP prediction"),
sidebarPanel(
numericInput(inputId =
"noofCYL",
label = "noofCYL",
min = 40, max = 160, value =
100),
actionButton('go',"Predict")
),
mainPanel( textOutput("value") )
)
)
server
<- function(input, output, session) {
data <- reactiveValues()
observeEvent(input$go,{
#browser()
data$var <-input$noofCYL
newPredict = data.frame(cyl=data$var)
modelLM = lm(hp~cyl, data = mtcars)
data$op = predict(modelLM, newPredict)
})
lstat = renderText({data$var})
output$value
<- renderPrint({data$op})
}
shinyApp(ui,
server)
No comments:
Post a Comment