edit-data | R Documentation |
data.frame
The module generates different options to edit a data.frame
: adding, deleting and modifying rows, exporting data (csv and excel), choosing editable columns, choosing mandatory columns.
This module returns the edited table with the user modifications.
edit_data_ui(id)
edit_data_server(
id,
data_r = reactive(NULL),
add = TRUE,
update = TRUE,
delete = TRUE,
download_csv = TRUE,
download_excel = TRUE,
file_name_export = "data",
var_edit = NULL,
var_mandatory = NULL,
return_class = c("data.frame", "data.table", "tbl_df", "raw")
)
id |
Module ID |
data_r |
data_r |
add |
|
update |
|
delete |
|
download_csv |
if |
download_excel |
if |
file_name_export |
|
var_edit |
vector of |
var_mandatory |
vector of |
return_class |
Class of returned data: |
the edited data.frame
in reactable format with the user modifications
library(shiny)
library(datamods)
library(bslib)
ui <- fluidPage(
theme = bs_theme(
version = 5
),
tags$h2(i18n("Edit data"), align = "center"),
edit_data_ui(id = "id"),
verbatimTextOutput("result")
)
server <- function(input, output, session) {
edited_r <- edit_data_server(
id = "id",
data_r = reactive(demo_edit),
add = TRUE,
update = TRUE,
delete = TRUE,
download_csv = TRUE,
download_excel = TRUE,
file_name_export = "datas",
# var_edit = c("name", "job", "credit_card_provider", "credit_card_security_code"),
var_mandatory = c("name", "job")
)
output$result <- renderPrint({
str(edited_r())
})
}
if (interactive())
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.