Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rkbarney/693feb2555d8f3dcb9cea80b3f7aa1d3 to your computer and use it in GitHub Desktop.
Save rkbarney/693feb2555d8f3dcb9cea80b3f7aa1d3 to your computer and use it in GitHub Desktop.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = 'Survey ETL Tool'),
dashboardSidebar(),
dashboardBody(
titlePanel(tableOutput('var.info')),
tags$div(id = 'placeholder')
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
dat <- iris
dnames <- names(dat)
lapply(1:length(dnames), function(i){
insertUI(
selector = '#placeholder',
ui = fluidRow(
textInput(paste0('varName',i,dnames[i], collapse = "_"),
label = dnames[i],
value = dnames[i]),
textAreaInput(paste0('varText',i,dnames[i], collapse = "_"),
label = "Variable text/description",
value = dnames[i],width = 700, resize = 'vertical'),
hr()
),
where = "beforeBegin",
multiple = T)
}
)
var.info <- reactive({{
app.inputs <- reactiveValuesToList(input)
var.names <- app.inputs[grepl("varName", names(app.inputs))]
var.text <- app.inputs[grepl("varText", names(app.inputs))]
var.names <- var.names[order(names(var.names))]
var.text <- var.text[order(names(var.text))]
var.names <- unlist(var.names, use.names=F)
var.text <- unlist(var.text, use.names=F)
cbind(var.names,var.text)
}})
output$var.info <- renderTable({var.info()})
}
# Run the application
shinyApp(ui = ui, server = server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment