So here is a reprex with the solution. The quick answer I was looking for can be found here in Section 2.2 "Data Tables Information"
https://rstudio.github.io/DT/shiny.html
library(shiny)
library(DT)
library(ggplot2)
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Linking GGPlot and DT::datatable"),
column(12,
mainPanel(
plotOutput("plot"),
dataTableOutput("carsTable")
)
)
)
server <- function(input, output) {
output$plot <- renderPlot({
# here is the secret to plot only the filtered rows:
# mtcars[input$carsTable_rows_all,]
ggplot(mtcars[input$carsTable_rows_all,], aes(x = drat, y = mpg)) +
geom_point()
})
output$carsTable <- DT::renderDataTable(mtcars, filter = "top",
options = list(pagelength = 100))
}
# Run the application
shinyApp(ui = ui, server = server)
Created on 2020-01-03 by the reprex package (v0.3.0)