Title: | `htmlwidget` for a Scatter Plot Matrix |
---|---|
Description: | Create a scatter plot matrix, using `htmlwidgets` package and `d3.js`. |
Authors: | David Chazalviel [aut, cre] |
Maintainer: | David Chazalviel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-12-15 07:22:19 UTC |
Source: | CRAN |
Three types of mouse interactions are available (tooltip
, filter
or zoom
).
changeMouseMode(id, interactionType)
changeMouseMode(id, interactionType)
id |
Output variable to read from (id which references the requested plot). |
interactionType |
Type of mouse interaction. |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "mouseMode", "Mouse Interactions:", c("Tooltip" = "tooltip", "Filter" = "filter", "Zoom" = "zoom") ), p("Selector controls type of mouse interactions with the scatterPlotMatrix"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ scatterPlotMatrix::changeMouseMode("spMatrix", input$mouseMode) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "mouseMode", "Mouse Interactions:", c("Tooltip" = "tooltip", "Filter" = "filter", "Zoom" = "zoom") ), p("Selector controls type of mouse interactions with the scatterPlotMatrix"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ scatterPlotMatrix::changeMouseMode("spMatrix", input$mouseMode) }) } shinyApp(ui, server) }
Result will be sent through a reactive input (see example below).
getPlotConfig(id, configInputId)
getPlotConfig(id, configInputId)
id |
Output variable to read from (id which references the requested plot). |
configInputId |
Reactive input to write to. |
No return value, called from shiny applications for side effects.
## Not run: library(shiny) library(shinyjs) library(scatterPlotMatrix) ui <- fluidPage( useShinyjs(), p("Button saves the widget as an html file, reproducing its configuration"), actionButton("downloadButton", "Download Widget"), downloadButton("associatedDownloadButton", "Download Widget", style = "visibility: hidden;" ), scatterPlotMatrixOutput("spMatrix", height = 960) ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observeEvent(input$downloadButton, { scatterPlotMatrix::getPlotConfig("spMatrix", "ConfigForDownload") }) observeEvent(input$ConfigForDownload, { spmForDownload <<- scatterPlotMatrix( data = iris, categorical = input$ConfigForDownload$categorical, inputColumns = input$ConfigForDownload$inputColumns, cutoffs = input$ConfigForDownload$cutoffs, keptColumns = input$ConfigForDownload$keptColumns, zAxisDim = input$ConfigForDownload$zAxisDim, distribType = as.numeric(input$ConfigForDownload$distribType), regressionType = as.numeric(input$ConfigForDownload$regressionType), corrPlotType = input$ConfigForDownload$corrPlotType, corrPlotCS = input$ConfigForDownload$corrPlotCS, rotateTitle = input$ConfigForDownload$rotateTitle, columnLabels = input$ConfigForDownload$columnLabels, continuousCS = input$ConfigForDownload$continuousCS, categoricalCS = input$ConfigForDownload$categoricalCS, mouseMode = input$ConfigForDownload$mouseMode, controlWidgets = NULL, cssRules = input$ConfigForDownload$cssRules, plotProperties = input$ConfigForDownload$plotProperties, slidersPosition = input$ConfigForDownload$slidersPosition ) shinyjs::runjs("document.getElementById('associatedDownloadButton').click();") }) output$associatedDownloadButton <- downloadHandler( filename = function() { paste("scatterPlotMatrix-", Sys.Date(), ".html", sep = "") }, content = function(tmpContentFile) { htmlwidgets::saveWidget(spmForDownload, tmpContentFile) } ) } shinyApp(ui, server) ## End(Not run)
## Not run: library(shiny) library(shinyjs) library(scatterPlotMatrix) ui <- fluidPage( useShinyjs(), p("Button saves the widget as an html file, reproducing its configuration"), actionButton("downloadButton", "Download Widget"), downloadButton("associatedDownloadButton", "Download Widget", style = "visibility: hidden;" ), scatterPlotMatrixOutput("spMatrix", height = 960) ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observeEvent(input$downloadButton, { scatterPlotMatrix::getPlotConfig("spMatrix", "ConfigForDownload") }) observeEvent(input$ConfigForDownload, { spmForDownload <<- scatterPlotMatrix( data = iris, categorical = input$ConfigForDownload$categorical, inputColumns = input$ConfigForDownload$inputColumns, cutoffs = input$ConfigForDownload$cutoffs, keptColumns = input$ConfigForDownload$keptColumns, zAxisDim = input$ConfigForDownload$zAxisDim, distribType = as.numeric(input$ConfigForDownload$distribType), regressionType = as.numeric(input$ConfigForDownload$regressionType), corrPlotType = input$ConfigForDownload$corrPlotType, corrPlotCS = input$ConfigForDownload$corrPlotCS, rotateTitle = input$ConfigForDownload$rotateTitle, columnLabels = input$ConfigForDownload$columnLabels, continuousCS = input$ConfigForDownload$continuousCS, categoricalCS = input$ConfigForDownload$categoricalCS, mouseMode = input$ConfigForDownload$mouseMode, controlWidgets = NULL, cssRules = input$ConfigForDownload$cssRules, plotProperties = input$ConfigForDownload$plotProperties, slidersPosition = input$ConfigForDownload$slidersPosition ) shinyjs::runjs("document.getElementById('associatedDownloadButton').click();") }) output$associatedDownloadButton <- downloadHandler( filename = function() { paste("scatterPlotMatrix-", Sys.Date(), ".html", sep = "") }, content = function(tmpContentFile) { htmlwidgets::saveWidget(spmForDownload, tmpContentFile) } ) } shinyApp(ui, server) ## End(Not run)
Asks to change the highlighted row.
highlightPoint(id, pointIndex)
highlightPoint(id, pointIndex)
id |
output variable to read from (id which references the requested plot) |
pointIndex |
index of the point to highlight; |
No return value, called from shiny applications for side effects.
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) }
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) }
htmlwidget
for d3.js
scatter plot matrixhtmlwidget
for d3.js
scatter plot matrix
scatterPlotMatrix( data, categorical = NULL, inputColumns = NULL, cutoffs = NULL, keptColumns = NULL, zAxisDim = NULL, distribType = 2, regressionType = 0, corrPlotType = "Circles", corrPlotCS = NULL, rotateTitle = FALSE, columnLabels = NULL, continuousCS = "Viridis", categoricalCS = "Category10", mouseMode = "tooltip", eventInputId = NULL, controlWidgets = FALSE, cssRules = NULL, plotProperties = NULL, slidersPosition = NULL, width = NULL, height = NULL, elementId = NULL )
scatterPlotMatrix( data, categorical = NULL, inputColumns = NULL, cutoffs = NULL, keptColumns = NULL, zAxisDim = NULL, distribType = 2, regressionType = 0, corrPlotType = "Circles", corrPlotCS = NULL, rotateTitle = FALSE, columnLabels = NULL, continuousCS = "Viridis", categoricalCS = "Category10", mouseMode = "tooltip", eventInputId = NULL, controlWidgets = FALSE, cssRules = NULL, plotProperties = NULL, slidersPosition = NULL, width = NULL, height = NULL, elementId = NULL )
data |
|
categorical |
List of list (one for each data column) containing the name of available categories,
or |
inputColumns |
List of boolean (one for each data column),
|
cutoffs |
List of |
keptColumns |
List of boolean (one for each data column), |
zAxisDim |
Name of the column represented by z axis
(used to determine the color to attribute to a point);
|
distribType |
Binary code indicating the type of distribution plot (bit 1: density plot, bit 2: histogram). |
regressionType |
Binary code indicating the type of regression plot (bit 1: linear, bit 2: loess). |
corrPlotType |
String indicating the type of correlation plots to use. Supported values:
|
corrPlotCS |
Name of the color Scale to use for correlation plot
when plot type is |
rotateTitle |
|
columnLabels |
List of string (one for each data column) to display
in place of column name found in data,
or |
continuousCS |
Name of the color Scale to use for continuous data;
supported names: |
categoricalCS |
Name of the color Scale to use for categorical data;
supported names: |
mouseMode |
Type of mouse interaction. Three types are available: |
eventInputId |
When plot event occurred, reactive input to write to;
|
controlWidgets |
Tells if some widgets must be available to control plot;
|
cssRules |
CSS rules to add. Must be a named list of the form list(selector = declarations), where selector is a valid CSS selector and declarations is a string or vector of declarations. |
plotProperties |
Adjust some properties which can not be set through CSS
(mainly size, color and opacity of points).
Default value is list( noCatColor = "#43665e", watermarkColor = "#ddd", point = list( alpha = 0.5, radius = 2 ), regression = list( strokeWidth = 4 ) ) |
slidersPosition |
Set initial position of sliders, specifying which columns intervals are visible.
Default value is list( dimCount = 8, xStartingDimIndex = 1, yStartingDimIndex = 1 ) |
width |
Integer in pixels defining the width of the widget. |
height |
Integer in pixels defining the height of the widget. |
elementId |
Unique |
if(interactive()) { library(scatterPlotMatrix) scatterPlotMatrix(iris, zAxisDim = "Species") # Each point has a color depending of its 'Species' value categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) scatterPlotMatrix(mtcars, categorical = categorical, zAxisDim = "cyl") # 'cyl' and four last columns have a box representation for categories # (use top slider to see the last three columns) scatterPlotMatrix(iris, zAxisDim = "Species", distribType = 1) # Distribution plots are of type 'density plot' (instead of histogram) scatterPlotMatrix(iris, zAxisDim = "Species", regressionType = 1) # Add linear regression plots columnLabels <- gsub("\\.", "<br>", colnames(iris)) scatterPlotMatrix(iris, zAxisDim = "Species", columnLabels = columnLabels) # Given names are displayed in place of dataset column names; # <br> is used to insert line breaks scatterPlotMatrix(iris, cssRules = list( ".jitterZone" = "fill: pink", ".tick text" = c("fill: red", "font-size: 1.8em") )) # Background of plot is pink and text of axes ticks is red and greater scatterPlotMatrix(iris, plotProperties = list( noCatColor = "DarkCyan", point = list( alpha = 0.3, radius = 4 ) )) # Points of plots are different: # two times greater, with opacity reduced from 0.5 to 0.3, and a `DarkCyan` color }
if(interactive()) { library(scatterPlotMatrix) scatterPlotMatrix(iris, zAxisDim = "Species") # Each point has a color depending of its 'Species' value categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) scatterPlotMatrix(mtcars, categorical = categorical, zAxisDim = "cyl") # 'cyl' and four last columns have a box representation for categories # (use top slider to see the last three columns) scatterPlotMatrix(iris, zAxisDim = "Species", distribType = 1) # Distribution plots are of type 'density plot' (instead of histogram) scatterPlotMatrix(iris, zAxisDim = "Species", regressionType = 1) # Add linear regression plots columnLabels <- gsub("\\.", "<br>", colnames(iris)) scatterPlotMatrix(iris, zAxisDim = "Species", columnLabels = columnLabels) # Given names are displayed in place of dataset column names; # <br> is used to insert line breaks scatterPlotMatrix(iris, cssRules = list( ".jitterZone" = "fill: pink", ".tick text" = c("fill: red", "font-size: 1.8em") )) # Background of plot is pink and text of axes ticks is red and greater scatterPlotMatrix(iris, plotProperties = list( noCatColor = "DarkCyan", point = list( alpha = 0.3, radius = 4 ) )) # Points of plots are different: # two times greater, with opacity reduced from 0.5 to 0.3, and a `DarkCyan` color }
Output and render functions for using scatterPlotMatrix within Shiny applications and interactive Rmd documents.
scatterPlotMatrixOutput(outputId, width = "100%", height = "600px") renderScatterPlotMatrix(expr, env = parent.frame(), quoted = FALSE)
scatterPlotMatrixOutput(outputId, width = "100%", height = "600px") renderScatterPlotMatrix(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a scatterPlotMatrix |
env |
The environment in which to evaluate |
quoted |
Is |
Tells which color scale to use when the Z axis is set to a categorical column.
setCategoricalColorScale(id, categoricalCsId)
setCategoricalColorScale(id, categoricalCsId)
id |
Output variable to read from (id which references the requested plot). |
categoricalCsId |
One of the available color scale ids (Category10, Accent, Dark2, Paired, Set1). |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "categoricalCsSelect", "Categorical Color Scale:", choices = list( "Category10" = "Category10", "Accent" = "Accent", "Dark2" = "Dark2", "Paired" = "Paired", "Set1" = "Set1" ), selected = "Category10" ), p("Selector controls used colors when reference column is of type categorical"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Species") }) observeEvent(input$categoricalCsSelect, { scatterPlotMatrix::setCategoricalColorScale("spMatrix", input$categoricalCsSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "categoricalCsSelect", "Categorical Color Scale:", choices = list( "Category10" = "Category10", "Accent" = "Accent", "Dark2" = "Dark2", "Paired" = "Paired", "Set1" = "Set1" ), selected = "Category10" ), p("Selector controls used colors when reference column is of type categorical"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Species") }) observeEvent(input$categoricalCsSelect, { scatterPlotMatrix::setCategoricalColorScale("spMatrix", input$categoricalCsSelect) }) } shinyApp(ui, server) }
Tells which color scale to use when the Z axis is set to a continuous column.
setContinuousColorScale(id, continuousCsId)
setContinuousColorScale(id, continuousCsId)
id |
Output variable to read from (id which references the requested plot). |
continuousCsId |
One of the available color scale ids
( |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "continuousCsSelect", "Continuous Color Scale:", choices = list( "Viridis" = "Viridis", "Inferno" = "Inferno", "Magma" = "Magma", "Plasma" = "Plasma", "Warm" = "Warm", "Cool" = "Cool", "Rainbow" ="Rainbow", "CubehelixDefault" = "CubehelixDefault", "Blues" = "Blues", "Greens" = "Greens", "Greys" = "Greys", "Oranges" = "Oranges", "Purples" = "Purples", "Reds" = "Reds", "BuGn" = "BuGn", "BuPu" = "BuPu", "GnBu" = "GnBu", "OrRd" = "OrRd", "PuBuGn" = "PuBuGn", "PuBu" = "PuBu", "PuRd" = "PuRd", "RdBu" = "RdBu", "RdPu" = "RdPu", "YlGnBu" = "YlGnBu", "YlGn" = "YlGn", "YlOrBr" = "YlOrBr", "YlOrRd" = "YlOrRd" ), selected = "Viridis" ), p("Selector controls used colors when reference column is of type continuous"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Sepal.Length") }) observeEvent(input$continuousCsSelect, { scatterPlotMatrix::setContinuousColorScale("spMatrix", input$continuousCsSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "continuousCsSelect", "Continuous Color Scale:", choices = list( "Viridis" = "Viridis", "Inferno" = "Inferno", "Magma" = "Magma", "Plasma" = "Plasma", "Warm" = "Warm", "Cool" = "Cool", "Rainbow" ="Rainbow", "CubehelixDefault" = "CubehelixDefault", "Blues" = "Blues", "Greens" = "Greens", "Greys" = "Greys", "Oranges" = "Oranges", "Purples" = "Purples", "Reds" = "Reds", "BuGn" = "BuGn", "BuPu" = "BuPu", "GnBu" = "GnBu", "OrRd" = "OrRd", "PuBuGn" = "PuBuGn", "PuBu" = "PuBu", "PuRd" = "PuRd", "RdBu" = "RdBu", "RdPu" = "RdPu", "YlGnBu" = "YlGnBu", "YlGn" = "YlGn", "YlOrBr" = "YlOrBr", "YlOrRd" = "YlOrRd" ), selected = "Viridis" ), p("Selector controls used colors when reference column is of type continuous"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Sepal.Length") }) observeEvent(input$continuousCsSelect, { scatterPlotMatrix::setContinuousColorScale("spMatrix", input$continuousCsSelect) }) } shinyApp(ui, server) }
Tells which color scale to use for correlation plots (only used when plot type is Text
or AbsText
).
setCorrPlotCS(id, corrPlotCsId)
setCorrPlotCS(id, corrPlotCsId)
id |
Output variable to read from (id which references the requested plot). |
corrPlotCsId |
One of the available color scale ids
( |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "corrPlotCsSelect", "Correlation Plot Color Scale:", choices = list( "Viridis" = "Viridis", "Inferno" = "Inferno", "Magma" = "Magma", "Plasma" = "Plasma", "Warm" = "Warm", "Cool" = "Cool", "Rainbow" ="Rainbow", "CubehelixDefault" = "CubehelixDefault", "Blues" = "Blues", "Greens" = "Greens", "Greys" = "Greys", "Oranges" = "Oranges", "Purples" = "Purples", "Reds" = "Reds", "BuGn" = "BuGn", "BuPu" = "BuPu", "GnBu" = "GnBu", "OrRd" = "OrRd", "PuBuGn" = "PuBuGn", "PuBu" = "PuBu", "PuRd" = "PuRd", "RdBu" = "RdBu", "RdPu" = "RdPu", "YlGnBu" = "YlGnBu", "YlGn" = "YlGn", "YlOrBr" = "YlOrBr", "YlOrRd" = "YlOrRd" ), selected = "Plasma" ), p("The selector controls the color scale to use for correlation plot when plot type is 'Text' or 'AbsText'"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, corrPlotType = "Text") }) observeEvent(input$corrPlotCsSelect, { scatterPlotMatrix::setCorrPlotCS("spMatrix", input$corrPlotCsSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "corrPlotCsSelect", "Correlation Plot Color Scale:", choices = list( "Viridis" = "Viridis", "Inferno" = "Inferno", "Magma" = "Magma", "Plasma" = "Plasma", "Warm" = "Warm", "Cool" = "Cool", "Rainbow" ="Rainbow", "CubehelixDefault" = "CubehelixDefault", "Blues" = "Blues", "Greens" = "Greens", "Greys" = "Greys", "Oranges" = "Oranges", "Purples" = "Purples", "Reds" = "Reds", "BuGn" = "BuGn", "BuPu" = "BuPu", "GnBu" = "GnBu", "OrRd" = "OrRd", "PuBuGn" = "PuBuGn", "PuBu" = "PuBu", "PuRd" = "PuRd", "RdBu" = "RdBu", "RdPu" = "RdPu", "YlGnBu" = "YlGnBu", "YlGn" = "YlGn", "YlOrBr" = "YlOrBr", "YlOrRd" = "YlOrRd" ), selected = "Plasma" ), p("The selector controls the color scale to use for correlation plot when plot type is 'Text' or 'AbsText'"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, corrPlotType = "Text") }) observeEvent(input$corrPlotCsSelect, { scatterPlotMatrix::setCorrPlotCS("spMatrix", input$corrPlotCsSelect) }) } shinyApp(ui, server) }
Tells which type of correlation plot to use.
setCorrPlotType(id, corrPlotType)
setCorrPlotType(id, corrPlotType)
id |
Output variable to read from (id which references the requested plot). |
corrPlotType |
One of the available correlation plot types ( |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "corrPlotTypeSelect", "Correlation Plot Type:", choices = list( "Empty" = "Empty", "Circles" = "Circles", "Text" = "Text", "AbsText" = "AbsText" ), selected = "Circles" ), p("The selector controls the type of correlation to use"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Sepal.Length", continuousCS = "Plasma") }) observeEvent(input$corrPlotTypeSelect, { scatterPlotMatrix::setCorrPlotType("spMatrix", input$corrPlotTypeSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "corrPlotTypeSelect", "Correlation Plot Type:", choices = list( "Empty" = "Empty", "Circles" = "Circles", "Text" = "Text", "AbsText" = "AbsText" ), selected = "Circles" ), p("The selector controls the type of correlation to use"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris, zAxisDim = "Sepal.Length", continuousCS = "Plasma") }) observeEvent(input$corrPlotTypeSelect, { scatterPlotMatrix::setCorrPlotType("spMatrix", input$corrPlotTypeSelect) }) } shinyApp(ui, server) }
Tells which cutoffs to use for each pair of columns. It's possible to filter some points by defining cutoffs to apply to columns.
setCutoffs(id, cutoffs)
setCutoffs(id, cutoffs)
id |
output variable to read from (id which references the requested plot) |
cutoffs |
List of |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( checkboxInput("setosaCB", "Setosa", TRUE), checkboxInput("versicolorCB", "Versicolor", TRUE), checkboxInput("viginicaCB", "Viginica", TRUE), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix( data = iris, zAxisDim = "Species" ) }) observe({ speciesCBs = c(input$setosaCB, input$versicolorCB, input$viginicaCB) toKeepIndexes <- Filter(function(i) speciesCBs[i], 1:length(speciesCBs)) xyCutoffs <- sapply(toKeepIndexes, function(i) { list(list(NULL, c(i - 1.1, i - 0.9))) }) scatterPlotMatrix::setCutoffs("spMatrix", list( list(xDim="Sepal.Length", yDim="Species", xyCutoffs = xyCutoffs) )) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( checkboxInput("setosaCB", "Setosa", TRUE), checkboxInput("versicolorCB", "Versicolor", TRUE), checkboxInput("viginicaCB", "Viginica", TRUE), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix( data = iris, zAxisDim = "Species" ) }) observe({ speciesCBs = c(input$setosaCB, input$versicolorCB, input$viginicaCB) toKeepIndexes <- Filter(function(i) speciesCBs[i], 1:length(speciesCBs)) xyCutoffs <- sapply(toKeepIndexes, function(i) { list(list(NULL, c(i - 1.1, i - 0.9))) }) scatterPlotMatrix::setCutoffs("spMatrix", list( list(xDim="Sepal.Length", yDim="Species", xyCutoffs = xyCutoffs) )) }) } shinyApp(ui, server) }
Tells which type of representation to use for distribution plots.
setDistribType(id, distribType)
setDistribType(id, distribType)
id |
Output variable to read from (id which references the requested plot). |
distribType |
Binary code indicating the type of distribution plot (bit 1: histogram, bit 2: density plot). |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "distribType", "Distribution Representation:", choices = list("Histogram" = 2, "Density Plot" = 1), selected = 2 ), p("The selector controls type of representation to use for distribution plots"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observeEvent(input$distribType, { scatterPlotMatrix::setDistribType("spMatrix", input$distribType) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( selectInput( "distribType", "Distribution Representation:", choices = list("Histogram" = 2, "Density Plot" = 1), selected = 2 ), p("The selector controls type of representation to use for distribution plots"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observeEvent(input$distribType, { scatterPlotMatrix::setDistribType("spMatrix", input$distribType) }) } shinyApp(ui, server) }
Tells which columns have to be visible.
setKeptColumns(id, keptColumns)
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) }
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) }
Tells which type of regression to use for regression plots.
setRegressionType(id, regressionType)
setRegressionType(id, regressionType)
id |
Output variable to read from (id which references the requested plot). |
regressionType |
Binary code indicating the type of regression plot (bit 1: linear, bit 2: loess). |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( checkboxInput("linearRegressionCB", "Linear Regression", FALSE), checkboxInput("loessCB", "Local Polynomial Regression", FALSE), p("The chech boxes controls type of regression to use for regression plots"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ linearFlag <- ifelse(input$linearRegressionCB, 1, 0) loessFlag <- ifelse(input$loessCB, 2, 0) scatterPlotMatrix::setRegressionType("spMatrix", linearFlag + loessFlag) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( checkboxInput("linearRegressionCB", "Linear Regression", FALSE), checkboxInput("loessCB", "Local Polynomial Regression", FALSE), p("The chech boxes controls type of regression to use for regression plots"), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ linearFlag <- ifelse(input$linearRegressionCB, 1, 0) loessFlag <- ifelse(input$loessCB, 2, 0) scatterPlotMatrix::setRegressionType("spMatrix", linearFlag + loessFlag) }) } shinyApp(ui, server) }
Tells which column to use as reference to determine color of each points.
setZAxis(id, dim)
setZAxis(id, dim)
id |
Output variable to read from (id which references the requested plot). |
dim |
name of the column to use as reference. |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( fluidRow( column( 2, selectInput("zAxisSelect", "Z Axis:", colnames(iris)) ), column( 2, checkboxInput("zAxisUsedCB", "Use Z Axis", FALSE) ) ), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ scatterPlotMatrix::setZAxis( "spMatrix", if (input$zAxisUsedCB) input$zAxisSelect else NULL ) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(scatterPlotMatrix) ui <- fluidPage( fluidRow( column( 2, selectInput("zAxisSelect", "Z Axis:", colnames(iris)) ), column( 2, checkboxInput("zAxisUsedCB", "Use Z Axis", FALSE) ) ), scatterPlotMatrixOutput("spMatrix") ) server <- function(input, output, session) { output$spMatrix <- renderScatterPlotMatrix({ scatterPlotMatrix(iris) }) observe({ scatterPlotMatrix::setZAxis( "spMatrix", if (input$zAxisUsedCB) input$zAxisSelect else NULL ) }) } shinyApp(ui, server) }