I have created the following Shiny App. It takes two values, it adds them to the table and when the button "Save" is hit it saves the table locally in a csv file. What I would like to do next (and I cannot wrap my mind around) is, every time I open the app to check if the file values already exists and, if TRUE to open that file and start adding from there:
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
# Define UI for application that draws a histogram
ui=pageWithSidebar(headerPanel("Adding entries to table"),
sidebarPanel(textInput("text1", "Column 1"),
textInput("text2", "Column 2"),
actionButton("update", "Update Table"),
actionButton("save", "Save")
) ,
mainPanel(tableOutput("table1")))
# Define server logic required to draw a histogram
server=function(input, output, session) {
values <- reactiveValues()
values$df <- data.frame(Column1 = NA, Column2 = NA)
newEntry <- observe({
if(input$update > 0) {
newLine <- isolate(c(input$text1, input$text2))
isolate(values$df <- rbind(values$df, newLine))
}
})
Save <- observe({
if(input$save > 0){
write.csv(values$df, "responses/values.csv", row.names = FALSE)
}
})
output$table1 <- renderTable({values$df})
}#Server End
# Run the application
shinyApp(ui = ui, server = server)