ui <- fluidPage( sidebarPanel( checkboxGroupInput("predictors_1", "Select Predictor variables for Model 1", names(df[,3:8])), # some data frame
actionButton("generate_1", "Generate", class = "btn-success"),
actionButton("reset_1", "Reset", class = "btn-danger"),
width = 3,
position="left"
)
mainPanel(
fluidRow(
column(width = 6,
verbatimTextOutput("model_1_summary"),
),
column(width = 6,
verbatimTextOutput("model_2_summary")
)
)
)
server <- function(input, output, session) {
rv1 <- reactiveValues()
# Functionality for Generate button
rv1$model_1_formula <- eventReactive(input$generate_1, {
reformulate( termlabels = input$predictors_1,
response = "Precipitation")})
# Printing Model 1 Summary
output$model_1_summary <- renderPrint(tryCatch(summary(lm(formula = rv1$model_1_formula(),
data = training_set)),
error = function(e) print("Select at least one Predictor and click Generate!")))
# Functionality for Reset Button
observeEvent(input$reset_1, {
updateTextInput(session, "predictors_1", value = "")
rv1$model_1_formula <- eventReactive(input$generate_1, {
reformulate( termlabels = input$predictors_1,
response = "Precipitation")})
})
}
My code is working in the following manner:
- I select the predictor variables
- Click on Generate button.
- Model summary is printed.
- I click on reset button.
- The inputs are updated to "", but the renderPrint output does not go away.
- Goto Step 1.
So the code is working but its not complete yet. Any help will be immensely appreciated.