I want to build a dynamic dataframe through several inputs, and then use this dataframe to get the predicted values from a mode I already had.
My code looks like this:
body <- dashboardBody(
tabItems(tabItem(tabName = "calculator",
box(
flowLayout(
numericInput('ra1', 'RA1', 0, min = 0, max = 1, step = 1),
numericInput('ra2', 'RA2',0, min = 0, max = 1, step = 1))))
ui <- dashboardPage(
dashboardHeader(title = "XXXXX", titleWidth = 300),
sidebar,
body
)
server <- function(input, output, session) {
dat <- reactive({
a <- as.integer(input$ra1)
b <- as.integer(input$ra2)
dat = cbind(a,b)
dat = as.data.frame(dat)
dat
})
pred <- reactive({
predict(y3, newdata = dat(), type="response")
})
}
shinyApp(ui, server)
But when running the code I get the following error:
Error in : object 'input' not found
Does anyone know what's going on? Really appreciate if anyone could give me some advice, thanks!