Created
May 7, 2018 15:25
-
-
Save rkbarney/a4166b5c31083071e869d0bb6b2a13d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
# Define UI for application that draws a histogram | |
ui <- fluidPage( | |
titlePanel(tableOutput('var.info')), | |
tags$div(id = 'placeholder') | |
) | |
# Define server logic required to draw a histogram | |
server <- function(input, output) { | |
dat.names <- colnames(iris) | |
print(dat.names) | |
test <- tagList( | |
for(i in 1:length(dat.names)){ | |
insertUI( | |
selector = "#placeholder", | |
where = "beforeEnd", | |
ui = fluidRow( | |
textInput(inputId = paste0("name",i), label = dat.names[i], value = dat.names[i]), | |
textAreaInput(paste0("text",i), | |
"Edit question text", | |
value = "", | |
width = "80%", | |
resize = "horizontal"), | |
hr() | |
) | |
) | |
} | |
) | |
var.info <- reactive({{ | |
app.inputs <- reactiveValuesToList(input) | |
var.names <- app.inputs[grepl("name[0-9]+", names(app.inputs))] | |
var.names <- unlist(var.names, use.names=FALSE) | |
var.text <- app.inputs[grepl("text[0-9]+", names(app.inputs))] | |
var.text <- unlist(var.text, use.names=FALSE) | |
data.frame(var.names,var.text) | |
}}) | |
output$var.info <- renderTable({var.info()}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) | |
Collapse | |
stephanie [8:45 PM] | |
this is awesome! | |
Message Input | |
Message @stephanie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment