1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| library(shiny)
library(rhandsontable)
ui<-fluidPage(
fluidRow(column(width = 4,
rHandsontableOutput("table")),
column(width = 4,
h3("Enregistrer la table"),
div(class='row',
div(class="col-sm-6",
tags$head(tags$script(src = "message-handler.js")),
actionButton("save", "Enregistrer"))
))
)
)
server<-function(input,output){
iris<-iris
iris$logical<-logical(length = length(iris))
output$table<-renderRHandsontable({
rhandsontable(iris)
})
data = reactive({
if (!is.null(input$table)) {
DF = hot_to_r(input$table)
} else {
DF =data
}
DF
})
observeEvent(input$save, {
write.table(data(), file = "iris.csv", append = FALSE,quote = FALSE, sep = ";",
eol = "\n", na = "NA", dec = ".", row.names = FALSE,
col.names = TRUE, qmethod = c("escape", "double"),
fileEncoding = "")
})
}
shinyApp(ui=ui,server=server) |
Partager