With the following Shiny App I would like to update the plot according to the ordering in the data table, i.e. if I sort the data by x
in the data table, it should automatically apply that sorting to the plot. How would I go about it? Does data table have an input variable like rows_selected
for the current sorting?
test-data
testdata <- data.frame(x = round(runif(10)*100), y = round(runif(10)*100))
rownames(testdata) <- LETTERS[1:10]
ui.R
require(DT)
ui <- fluidPage(
fluidRow(
plotOutput("plot")
),
fluidRow(
DT::dataTableOutput("table")
)
)
server.R
server <- function(input, output) {
output$plot <- renderPlot({
barplot(testdata[,1])
})
output$table <- DT::renderDataTable({
DT::datatable(
testdata
)
})
}
shinyApp(ui, server)