Learn R Programming

scatterPlotMatrix (version 0.3.0)

highlightPoint: Row highlight

Description

Asks to change the highlighted row.

Usage

highlightPoint(id, pointIndex)

Value

No return value, called from shiny applications for side effects.

Arguments

id

output variable to read from (id which references the requested plot)

pointIndex

index of the point to highlight; NULL means no point is to highlight.

Examples

Run this code
 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