View source: R/scatterPlotMatrix.R
setKeptColumns | R Documentation |
Tells which columns have to be visible.
setKeptColumns(id, keptColumns)
id |
Output variable to read from (id which references the requested plot). |
keptColumns |
Vector of boolean (one for each data column), |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) {
library(shiny)
library(scatterPlotMatrix)
ui <- fluidPage(
checkboxInput("hideColumnsCB", "Hide last columns", FALSE),
p("The check box controls the visibility of the two last columns"),
scatterPlotMatrixOutput("spMatrix")
)
server <- function(input, output, session) {
output$spMatrix <- renderScatterPlotMatrix({
scatterPlotMatrix(iris)
})
observeEvent(input$hideColumnsCB, {
keptColumns <- vapply(
1:ncol(iris),
function(i) {
return(ifelse(input$hideColumnsCB, ncol(iris) - i >= 2, TRUE))
},
logical(1)
)
scatterPlotMatrix::setKeptColumns("spMatrix", keptColumns)
})
}
shinyApp(ui, server)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.