Skip to content

Instantly share code, notes, and snippets.

@christopherlovell
Last active September 7, 2023 11:51
Show Gist options
  • Select an option

  • Save christopherlovell/b7ecdf8b0aa82c20fa46 to your computer and use it in GitHub Desktop.

Select an option

Save christopherlovell/b7ecdf8b0aa82c20fa46 to your computer and use it in GitHub Desktop.

Revisions

  1. christopherlovell revised this gist Aug 19, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions app.R
    Original file line number Diff line number Diff line change
    @@ -5,15 +5,15 @@ server <- function(input, output) {
    num <- as.integer(input$num)

    lapply(1:num, function(i) {
    numericInput(paste("n_input_", i, sep=""), label = paste("n_input", i, sep=""), value = 0)
    numericInput(paste0("n_input_", i), label = paste0("n_input", i), value = 0)
    })
    })

    output$table <- renderTable({
    num <- as.integer(input$num)

    data.frame(lapply(1:num, function(i) {
    input[[paste("n_input_", i, sep="")]]
    input[[paste0("n_input_", i)]]
    }))
    })

  2. christopherlovell created this gist Aug 19, 2015.
    34 changes: 34 additions & 0 deletions app.R
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    library(shiny)

    server <- function(input, output) {
    output$input_ui <- renderUI({
    num <- as.integer(input$num)

    lapply(1:num, function(i) {
    numericInput(paste("n_input_", i, sep=""), label = paste("n_input", i, sep=""), value = 0)
    })
    })

    output$table <- renderTable({
    num <- as.integer(input$num)

    data.frame(lapply(1:num, function(i) {
    input[[paste("n_input_", i, sep="")]]
    }))
    })

    }

    ui <- fluidPage(
    sidebarLayout(
    sidebarPanel(
    selectInput("num", "select number of inputs", choices = seq(1,10,1))
    ),
    mainPanel(
    uiOutput("input_ui"),
    tableOutput("table")
    )
    )
    )

    shinyApp(ui = ui, server = server)