Reputation: 135
In my shiny app, I am using shinyWidgets (like, actionBttn) and they really look fantastic. However I couldn't find a shinyWidgets button that has a similar function to "shinySaveButton" for saving files. Although shinySaveButton is very functional and easy to use, it doesn't look nice among other shinyWidgets buttons. How can I sort this out?
Easy to code, with full file saving functionality: ''' shinySaveButton("save", "Save file", "Save file as ...", filetype=list(csv="csv")) '''
Looks great but no file saving functionality: ''' actionBttn(inputId = "save", label = "Save", size="sm", color = "primary", style = "gradient", icon = icon("save"), block = FALSE) '''
Upvotes: 0
Views: 177
Reputation: 160
If on the UI side you have got something like that
actionBttn(
inputId = "save",
label = "Go!",
color = "primary",
style = "bordered"
)
Then on the server side you would be able to implement a logic that save a file:
observeEvent(input$save, {
write.csv(x = object_to_save, file = 'file.csv')
})
Obviously you have to define object_to_save first.
And this would save object_to_save in file.csv in your working directory, if you want to put it somewhre else, you should use the full path: /here/is/my/path/file.csv
Also there is not only write.csv to save a file, there is a lot a function that allows you to save files in different format as save or saveRDS for example.
Upvotes: 0