if(interactive() && require(shiny)) {
library(shiny)
library(scatterPlotMatrix)
ui <- fluidPage(
actionButton("highlightPointAction", "Highlight Last Point"),
actionButton("clearHlPointAction", "Remove Highlighting"),
p("These buttons sets/unsets a selected line"),
scatterPlotMatrixOutput("spMatrix")
)
server <- function(input, output, session) {
output$spMatrix <- renderScatterPlotMatrix({
scatterPlotMatrix(iris)
})
observeEvent(input$highlightPointAction, {
lastRowIndex <- nrow(iris)
scatterPlotMatrix::highlightPoint("spMatrix", lastRowIndex)
})
observeEvent(input$clearHlPointAction, {
scatterPlotMatrix::highlightPoint("spMatrix", NULL)
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab