Hi,
Excellent and much needed implementation.
I found an issue with date and time inputs when using local tables as storage system: their posix elements are spread across multiple columns. Small example below.
library(shiny)
outputDir <- "RESPONSES"
fields <- c("Date", "Time")
saveData <- function(data) {
data <- t(data)
fileName <- sprintf("%s_%s.csv", as.integer(Sys.time()), digest::digest(data))
write.csv(
x = data,
file = file.path(outputDir, fileName),
row.names = FALSE, quote = TRUE
)
}
loadData <- function() {
files <- list.files(outputDir, full.names = TRUE)
data <- lapply(files, read.csv, stringsAsFactors = FALSE)
data <- do.call(rbind, data)
data
}
ui <- fluidPage(
dateInput("Date", "Date",
format = "ddmmyyyy",
value = ""),
timeInput("Time", "Time",
seconds = F),
actionButton("Submit", "Submit", width = "280px"),
hr(),
DT::dataTableOutput("responses", width = 300), tags$hr()
)
server = function(input, output, session) {
formData <- reactive({
data <- sapply(fields, function(x) input[[x]])
data
})
observeEvent(input$Submeter, {
saveData(formData())
})
output$responses <- DT::renderDataTable({
input$Submeter
loadData()
})
}
shinyApp(ui, server)