Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Created May 30, 2017 06:43
Show Gist options
  • Save aagarw30/4f10bad8aa94d47e024934350c16f2b8 to your computer and use it in GitHub Desktop.
Save aagarw30/4f10bad8aa94d47e024934350c16f2b8 to your computer and use it in GitHub Desktop.
Delete specific rows from data frame using reactiveValues() - example
library(shiny)
shinyServer((function(input, output) {
values <- reactiveValues(df = NULL)
observeEvent(input$file, {
values$df <- read.csv(input$file$datapath)
})
observeEvent(input$delete, {
values$df <- values$df[-input$rowno, ]
})
output$new_df <- renderTable(values$df)
}))
library(shiny)
shinyUI((fluidPage(
"Delete specific rows from dataframe using reactiveValues() - example",
br(),
mainPanel(
fileInput("file", "Upload file"),
numericInput("rowno", "Delete row:", 1, step = 1),
actionButton("delete", "Delete this row"),
tableOutput("new_df")
)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment