add_inputs: Create multiple textInput functions in Shiny

View source: R/add_inputs.R

add_inputsR Documentation

Create multiple textInput functions in Shiny

Description

For use in the shiny_emissions() function. Adding an unknown quantity of textInputs.

Usage

add_inputs(numeric_input, label, value)

Arguments

numeric_input

Name of numerical input that controls the number of items to add.

label

Label of new textInput.

value

Value of new textInput.

Value

Returns textInput for use in the shiny_emissions() function.

Examples

if(interactive()) {
ui <- shinydashboard::dashboardPage(header = shinydashboard::dashboardHeader(),
                                    sidebar = shinydashboard::dashboardSidebar(),
                                    shinydashboard::dashboardBody(
                                    shiny::fluidRow(
                                    shiny::column(12, align = "left",
                                    shiny::splitLayout(shinydashboard::box(width = NULL,
                                    shiny::numericInput("newbox_add",
                                                        "Number of new boxes:",
                                                        value = 0, min = 0),
                                    shiny::uiOutput("newbox_input")))))))
server <- function(input, output) {
  K_plane <- shiny::reactive({ input$newbox_add })
  output$newbox_input <- shiny::renderUI({ add_inputs(numeric_input = K_plane(),
                                                      label = "New Box:",
                                                      value = "textbox") })
}
shiny::shinyApp(ui, server)
}

carbonr documentation built on Oct. 17, 2024, 1:06 a.m.