This could get you started:
ui.R
library(shiny)
library(DT)
shinyUI(fluidPage(
titlePanel("Delete rows with DT"),
sidebarLayout(
sidebarPanel(
actionButton("deleteRows", "Delete Rows")
),
mainPanel(
dataTableOutput("table1")
)
)
))
server.R
library(shiny)
library(DT)
library(dplyr)
df <- data.frame(x = 1:10, y = letters[1:10])
shinyServer(function(input, output) {
values <- reactiveValues(dfWorking = df)
observeEvent(input$deleteRows,{
if (!is.null(input$table1_rows_selected)) {
values$dfWorking <- values$dfWorking[-as.numeric(input$table1_rows_selected),]
}
})
output$table1 <- renderDataTable({
values$dfWorking
})
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…