Hello,
I am working on a Shiny project where I have a tab for a regression output using renderPrint. I am using a selectInput to allow the user to choose multiple independent variables to include in the model. The output can grow longer based on the number of independent variables the user selects for the model. Here is an example of what I'm doing:
library(shinythemes)
library(shinyWidgets)
library(shiny)
library(shinydashboard)
library(DT)
library(ggplot2)
library(zoo)
library(dplyr)
library(htmltools)
library(formattable)
IndVarChoices<-c("cyl","disp","hp","drat","wt","qsec","vs","am", "gear","carb")
# Define UI for application
ui <- fluidPage(
navbarPage("Example",
tabPanel("Regression",
tabname="regression",
icon=icon("chart-line"),
fluidPage(column(width=6,
selectInput(inputId = "indep",
label = "Choose Independent Variable(s) to Include:",
multiple = TRUE,
choices = as.list(IndVarChoices),
selected = IndVarChoices[1:2]),
verbatimTextOutput(outputId = "RegOut"))))))
# Define server logic
server <- function(input, output) {
#Reactive portions of this tab
recipe_formula <- reactive(mtcars %>%
recipe() %>%
update_role(mpg,new_role = "outcome") %>%
update_role(!!!input$indep,new_role = "predictor") %>%
formula())
lm_reg <- reactive(
lm(recipe_formula(),data = mtcars)
)
#Output portions of this tab
output$RegOut <- renderPrint({
summary(lm_reg())
})
}
# Run the application
shinyApp(ui = ui, server = server)
I want to be able to force the length of the output to stay at a certain length. I would ideally like to have a vertical scroll bar appear that allows the user to scroll down to the bottom of the output. I plan to have this output next to another plot that doesn't grow, so it'll look a little weird when one output is longer than the other if the user selects a bunch of independent variables in the model.
Can someone help point me in the right direction? Any help would be appreciated! Thank you!
...