Learn R Programming

carbonr (version 0.2.1)

add_inputs: 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)

Value

Returns textInput for use in the shiny_emissions() function.

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.

Examples

Run this code
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)
}

Run the code above in your browser using DataLab