Much like the edit function in R, I would like to manually make changes to a data frame from within Shiny. I have been to the shiny website
http://shiny.rstudio.com/gallery/datatables-options.html
however, I have not find a place where I can manually change data.
you can do what you want with shinysky package. It offer functionality to edit your tables on demand. Below is a simple example with mtcars dataset where you can change the table content and then download the updates you introduced during the session. You can easily add the file input to read .csv files yourself
rm(list = ls())
library(shiny)
library(shinydashboard)
library(shinysky)
ui <- dashboardPage(
dashboardHeader(title = "How to edit a table"),
dashboardSidebar(sidebarMenu(id = "tabs",menuItem("Menu Item 1", tabName = "one", icon = icon("dashboard"))
)),
dashboardBody(
tabItems(tabItem(tabName = "one",hotable("hotable1"),downloadButton('downloadData', 'Download')))
))
server <- function(input, output) {
previous <- reactive({mtcars})
sample_data <- reactive({
if(is.null(input$hotable1)){return(previous())}
else if(!identical(previous(),input$hotable1))
{
sample_data <- as.data.frame(hot.to.df(input$hotable1))
sample_data
}
})
output$hotable1 <- renderHotable({sample_data()}, readOnly = F)
output$downloadData <- downloadHandler(filename = function() {paste(Sys.time(), '- My New Table.csv', sep='') },content = function(file) {write.csv(sample_data(), file, row.names = FALSE)})
}
shinyApp(ui, server)

The downloaded file looks like so:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With