Title: | `htmlwidget` for a Parallel Coordinates Plot |
---|---|
Description: | Create a parallel coordinates plot, using `htmlwidgets` package and `d3.js`. |
Authors: | David Chazalviel [aut, cre], Benoit Lehman [aut] |
Maintainer: | David Chazalviel <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.0 |
Built: | 2024-12-15 07:21:39 UTC |
Source: | CRAN |
Asks to change a row.
changeRow(id, rowIndex, newValues)
changeRow(id, rowIndex, newValues)
id |
output variable to read from (id which references the requested plot) |
rowIndex |
index of the changed row. |
newValues |
list of new values to attribute to the row (list associating a value to a column identifier). |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( sliderInput( "rowValueSlider", "Value for 'Sepal.Length' of first row:", min = 4, max = 8, step = 0.1, value = iris[["Sepal.Length"]][1] ), p("Slider controls the new value to assign to 'Sepal.Length' of the first row"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$rowValueSlider, { newValues <- iris[1,] newValues[["Sepal.Length"]] <- input$rowValueSlider parallelPlot::changeRow("parPlot", 1, newValues) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( sliderInput( "rowValueSlider", "Value for 'Sepal.Length' of first row:", min = 4, max = 8, step = 0.1, value = iris[["Sepal.Length"]][1] ), p("Slider controls the new value to assign to 'Sepal.Length' of the first row"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$rowValueSlider, { newValues <- iris[1,] newValues[["Sepal.Length"]] <- input$rowValueSlider parallelPlot::changeRow("parPlot", 1, newValues) }) } 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: if(interactive() && require(shiny)) { library(shiny) library(shinyjs) library(parallelPlot) ui <- fluidPage( useShinyjs(), p("Use button to save widget as an html file, reproducing its configuration"), actionButton("downloadButton", "Download Widget"), downloadButton("associatedDownloadButton", "Download Widget", style = "visibility: hidden;" ), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$downloadButton, { parallelPlot::getPlotConfig("parPlot", "ConfigForDownload") }) observeEvent(input$ConfigForDownload, { ppForDownload <<- parallelPlot( data = iris, categorical = input$ConfigForDownload$categorical, categoriesRep = input$ConfigForDownload$categoriesRep, arrangeMethod = input$ConfigForDownload$arrangeMethod, inputColumns = input$ConfigForDownload$inputColumns, keptColumns = input$ConfigForDownload$keptColumns, histoVisibility = input$ConfigForDownload$histoVisibility, invertedAxes = input$ConfigForDownload$invertedAxes, cutoffs = input$ConfigForDownload$cutoffs, refRowIndex = input$ConfigForDownload$refRowIndex, refColumnDim = input$ConfigForDownload$refColumnDim, rotateTitle = input$ConfigForDownload$rotateTitle, columnLabels = input$ConfigForDownload$columnLabels, continuousCS = input$ConfigForDownload$continuousCS, categoricalCS = input$ConfigForDownload$categoricalCS, controlWidgets = NULL, cssRules = input$ConfigForDownload$cssRules, sliderPosition = input$ConfigForDownload$sliderPosition ) shinyjs::runjs("document.getElementById('associatedDownloadButton').click();") }) output$associatedDownloadButton <- downloadHandler( filename = function() { paste("parallelPlot-", Sys.Date(), ".html", sep = "") }, content = function(tmpContentFile) { htmlwidgets::saveWidget(ppForDownload, tmpContentFile) } ) } shinyApp(ui, server) } ## End(Not run)
## Not run: if(interactive() && require(shiny)) { library(shiny) library(shinyjs) library(parallelPlot) ui <- fluidPage( useShinyjs(), p("Use button to save widget as an html file, reproducing its configuration"), actionButton("downloadButton", "Download Widget"), downloadButton("associatedDownloadButton", "Download Widget", style = "visibility: hidden;" ), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$downloadButton, { parallelPlot::getPlotConfig("parPlot", "ConfigForDownload") }) observeEvent(input$ConfigForDownload, { ppForDownload <<- parallelPlot( data = iris, categorical = input$ConfigForDownload$categorical, categoriesRep = input$ConfigForDownload$categoriesRep, arrangeMethod = input$ConfigForDownload$arrangeMethod, inputColumns = input$ConfigForDownload$inputColumns, keptColumns = input$ConfigForDownload$keptColumns, histoVisibility = input$ConfigForDownload$histoVisibility, invertedAxes = input$ConfigForDownload$invertedAxes, cutoffs = input$ConfigForDownload$cutoffs, refRowIndex = input$ConfigForDownload$refRowIndex, refColumnDim = input$ConfigForDownload$refColumnDim, rotateTitle = input$ConfigForDownload$rotateTitle, columnLabels = input$ConfigForDownload$columnLabels, continuousCS = input$ConfigForDownload$continuousCS, categoricalCS = input$ConfigForDownload$categoricalCS, controlWidgets = NULL, cssRules = input$ConfigForDownload$cssRules, sliderPosition = input$ConfigForDownload$sliderPosition ) shinyjs::runjs("document.getElementById('associatedDownloadButton').click();") }) output$associatedDownloadButton <- downloadHandler( filename = function() { paste("parallelPlot-", Sys.Date(), ".html", sep = "") }, content = function(tmpContentFile) { htmlwidgets::saveWidget(ppForDownload, tmpContentFile) } ) } shinyApp(ui, server) } ## End(Not run)
Asks to retrieve the value of an attribute.
getValue(id, attrType, valueInputId)
getValue(id, attrType, valueInputId)
id |
output variable to read from (id which references the requested plot) |
attrType |
which value is requested. |
valueInputId |
reactive input to write to. |
Available attributes are Cutoffs
, SelectedTraces
and ReferenceColumn
.
Result will be sent through a reactive input.
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( actionButton("getSelectedTracesAction", "Retrieve Selected Lines"), p("The button displays the list of uncutted rows (use brush to reduce it)"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$getSelectedTracesAction, { attributeType <- "SelectedTraces" parallelPlot::getValue("parPlot", attributeType, "MySelectedTraces") }) observeEvent(input$MySelectedTraces, { showModal(modalDialog( title = "Selected Lines", toString(input$MySelectedTraces) )) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( actionButton("getSelectedTracesAction", "Retrieve Selected Lines"), p("The button displays the list of uncutted rows (use brush to reduce it)"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$getSelectedTracesAction, { attributeType <- "SelectedTraces" parallelPlot::getValue("parPlot", attributeType, "MySelectedTraces") }) observeEvent(input$MySelectedTraces, { showModal(modalDialog( title = "Selected Lines", toString(input$MySelectedTraces) )) }) } shinyApp(ui, server) }
Asks to change the highlighted row.
highlightRow(id, rowIndex)
highlightRow(id, rowIndex)
id |
output variable to read from (id which references the requested plot) |
rowIndex |
index of the row to highlight; |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( actionButton("highlightRowAction", "Highlight Last Row"), actionButton("clearHlRowAction", "Remove Highlighting"), p("These buttons sets/unsets a selected line"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$highlightRowAction, { lastRowIndex <- nrow(iris) parallelPlot::highlightRow("parPlot", lastRowIndex) }) observeEvent(input$clearHlRowAction, { parallelPlot::highlightRow("parPlot", NULL) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( actionButton("highlightRowAction", "Highlight Last Row"), actionButton("clearHlRowAction", "Remove Highlighting"), p("These buttons sets/unsets a selected line"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$highlightRowAction, { lastRowIndex <- nrow(iris) parallelPlot::highlightRow("parPlot", lastRowIndex) }) observeEvent(input$clearHlRowAction, { parallelPlot::highlightRow("parPlot", NULL) }) } shinyApp(ui, server) }
htmlwidget
for d3.js
parallel coordinate plothtmlwidget
for d3.js
parallel coordinate plot
parallelPlot( data, categorical = NULL, categoriesRep = "EquallySpacedLines", arrangeMethod = "fromRight", inputColumns = NULL, keptColumns = NULL, histoVisibility = NULL, invertedAxes = NULL, cutoffs = NULL, refRowIndex = NULL, refColumnDim = NULL, rotateTitle = FALSE, columnLabels = NULL, continuousCS = "Viridis", categoricalCS = "Category10", eventInputId = NULL, editionMode = "EditionOff", controlWidgets = FALSE, cssRules = NULL, sliderPosition = NULL, width = NULL, height = NULL, elementId = NULL )
parallelPlot( data, categorical = NULL, categoriesRep = "EquallySpacedLines", arrangeMethod = "fromRight", inputColumns = NULL, keptColumns = NULL, histoVisibility = NULL, invertedAxes = NULL, cutoffs = NULL, refRowIndex = NULL, refColumnDim = NULL, rotateTitle = FALSE, columnLabels = NULL, continuousCS = "Viridis", categoricalCS = "Category10", eventInputId = NULL, editionMode = "EditionOff", controlWidgets = FALSE, cssRules = NULL, sliderPosition = NULL, width = NULL, height = NULL, elementId = NULL )
data |
|
categorical |
List of list (one for each data column) containing the name of available categories,
or |
categoriesRep |
Within a category column, the height assigned to each category can either be:
|
arrangeMethod |
Within a category box:
|
inputColumns |
List of boolean (one for each data column),
|
keptColumns |
List of boolean (one for each data column), |
histoVisibility |
List of boolean (one for each data column), |
invertedAxes |
List of boolean (one for each data column), |
cutoffs |
List of list (one for each data column) of list (one for each cutoff)
containing two values (min and max values defining the cutoff)
or |
refRowIndex |
Index of the sample row which has to appear horizontal;
|
refColumnDim |
Name of the reference column (used to determine the color to attribute to a row);
|
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: Category10, Accent, Dark2, Paired, Set1;
default value is |
eventInputId |
When plot event occurred, reactive input to write to;
|
editionMode |
Supported edition modes: |
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. |
sliderPosition |
Set initial position of slider, specifying which columns interval is visible.
Default value is list( dimCount = 8, startingDimIndex = 1 ) |
width |
Integer in pixels defining the width of the widget. |
height |
Integer in pixels defining the height of the widget. |
elementId |
Unique |
An object of class htmlwidget
that will intelligently print itself into HTML
in a variety of contexts including the R console, within R Markdown documents,
and within Shiny output bindings.
if(interactive()) { library(parallelPlot) categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") # `cyl` and four last columns have a box representation for categories histoVisibility <- rep(TRUE, ncol(iris)) parallelPlot(iris, histoVisibility = histoVisibility) # An histogram is displayed for each column histoVisibility <- names(iris) # Same as `rep(TRUE, ncol(iris))` cutoffs <- list(Sepal.Length = list(c(6, 7)), Species = c("virginica", "setosa")) parallelPlot(iris, histoVisibility = histoVisibility, cutoffs = cutoffs) # Cut lines are shaded; # an histogram for each column is displayed considering only kept lines parallelPlot(iris, refRowIndex = 1) # Axes are shifted vertically in such a way that first trace # of the dataset looks horizontal columnLabels <- gsub("\\.", "<br>", colnames(iris)) parallelPlot(iris, refColumnDim = "Species", columnLabels = columnLabels) # Given names are displayed in place of dataset column names; # <br> is used to insert line breaks parallelPlot(iris, cssRules = list( "svg" = "background: #C2C2C2", ".tick text" = c("fill: red", "font-size: 1.8em") )) # Background of plot is grey and text of axes ticks is red and greater }
if(interactive()) { library(parallelPlot) categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") # `cyl` and four last columns have a box representation for categories histoVisibility <- rep(TRUE, ncol(iris)) parallelPlot(iris, histoVisibility = histoVisibility) # An histogram is displayed for each column histoVisibility <- names(iris) # Same as `rep(TRUE, ncol(iris))` cutoffs <- list(Sepal.Length = list(c(6, 7)), Species = c("virginica", "setosa")) parallelPlot(iris, histoVisibility = histoVisibility, cutoffs = cutoffs) # Cut lines are shaded; # an histogram for each column is displayed considering only kept lines parallelPlot(iris, refRowIndex = 1) # Axes are shifted vertically in such a way that first trace # of the dataset looks horizontal columnLabels <- gsub("\\.", "<br>", colnames(iris)) parallelPlot(iris, refColumnDim = "Species", columnLabels = columnLabels) # Given names are displayed in place of dataset column names; # <br> is used to insert line breaks parallelPlot(iris, cssRules = list( "svg" = "background: #C2C2C2", ".tick text" = c("fill: red", "font-size: 1.8em") )) # Background of plot is grey and text of axes ticks is red and greater }
Output and render functions for using parallelPlot within Shiny applications and interactive Rmd documents.
parallelPlotOutput(outputId, width = "100%", height = "600px") renderParallelPlot(expr, env = parent.frame(), quoted = FALSE)
parallelPlotOutput(outputId, width = "100%", height = "600px") renderParallelPlot(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 parallelPlot |
env |
The environment in which to evaluate |
quoted |
Is |
An output or render function that enables the use of the widget within Shiny applications.
Within a category box:
the position of lines can be calculated to minimize
crossings on the left of the box (fromLeft
);
the position of lines can be calculated to minimize
crossings on the right (fromRight
, default behavior);
lines can be split in two points to minimize crossings
on the left and on the right (fromBoth
).
To turn this ordering off (for example for performance reasons),
arrangeMethod
can also be set to fromNone
.
setArrangeMethod(id, arrangeMethod)
setArrangeMethod(id, arrangeMethod)
id |
Output variable to read from (id which references the requested plot). |
arrangeMethod |
One of the available arrange methods ( |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "arrangeMethodSelect", "Arrange Method:", choices = list( "fromLeft" = "fromLeft", "fromRight" = "fromRight", "fromBoth" = "fromBoth", "fromNone" = "fromNone" ), selected = "fromRight" ), p("Selector controls the method used to arrange lines position in category boxes"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") }) observeEvent(input$arrangeMethodSelect, { parallelPlot::setArrangeMethod("parPlot", input$arrangeMethodSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "arrangeMethodSelect", "Arrange Method:", choices = list( "fromLeft" = "fromLeft", "fromRight" = "fromRight", "fromBoth" = "fromBoth", "fromNone" = "fromNone" ), selected = "fromRight" ), p("Selector controls the method used to arrange lines position in category boxes"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") }) observeEvent(input$arrangeMethodSelect, { parallelPlot::setArrangeMethod("parPlot", input$arrangeMethodSelect) }) } shinyApp(ui, server) }
Tells which color scale to use when reference column is of type categorical.
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 |
If a column is defined as the reference (for example by clicking on its header),
a color scale is associated to this column.
Available color scale ids are: Category10
, Accent
, Dark2
, Paired
, Set1
.
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) 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"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(data = iris, refColumnDim = "Species") }) observeEvent(input$categoricalCsSelect, { parallelPlot::setCategoricalColorScale("parPlot", input$categoricalCsSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) 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"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(data = iris, refColumnDim = "Species") }) observeEvent(input$categoricalCsSelect, { parallelPlot::setCategoricalColorScale("parPlot", input$categoricalCsSelect) }) } shinyApp(ui, server) }
Within a category column, the height assigned to each category can either be:
equal for each category (EquallySizedBoxes
);
or calculated to reflect the proportion of lines
passing through each category (EquallySpacedLines
).
setCategoriesRep(id, categoriesRep)
setCategoriesRep(id, categoriesRep)
id |
Output variable to read from (id which references the requested plot). |
categoriesRep |
One of the available category representations
( |
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "categoriesRepSelect", "Categories Representation:", choices = list( "EquallySpacedLines" = "EquallySpacedLines", "EquallySizedBoxes" = "EquallySizedBoxes" ), selected = "EquallySpacedLines" ), p("The selector controls the height assigned to each category"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") }) observeEvent(input$categoriesRepSelect, { parallelPlot::setCategoriesRep("parPlot", input$categoriesRepSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "categoriesRepSelect", "Categories Representation:", choices = list( "EquallySpacedLines" = "EquallySpacedLines", "EquallySizedBoxes" = "EquallySizedBoxes" ), selected = "EquallySpacedLines" ), p("The selector controls the height assigned to each category"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical, refColumnDim = "cyl") }) observeEvent(input$categoriesRepSelect, { parallelPlot::setCategoriesRep("parPlot", input$categoriesRepSelect) }) } shinyApp(ui, server) }
Tells which color scale to use when reference column is of type continuous.
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
( |
If a column is defined as the reference (for example by clicking on its header),
a color scale is associated to this column.
Available color scale ids are: Blues
, RdBu
, YlGnBu
, YlOrRd
, Reds
.
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) 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"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris, refColumnDim = "Sepal.Length") }) observeEvent(input$continuousCsSelect, { parallelPlot::setContinuousColorScale("parPlot", input$continuousCsSelect) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) 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"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris, refColumnDim = "Sepal.Length") }) observeEvent(input$continuousCsSelect, { parallelPlot::setContinuousColorScale("parPlot", input$continuousCsSelect) }) } shinyApp(ui, server) }
Tells which cutoffs to use for each column.
setCutoffs(id, cutoffs)
setCutoffs(id, cutoffs)
id |
output variable to read from (id which references the requested plot) |
cutoffs |
Vector of list (one for each data column) of vector (one for each cutoff)
containing two values for continuous input (min and max value defining the cutoff),
or one value for categorical input (name of the category to keep),
or |
It's possible to filter some lines by defining cutoffs to apply to columns.
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( sliderInput("brushSlider", "Brush for 'Sepal.Length' column:", min = 4, max = 8, step = 0.1, value = c(4, 8)), p("The slider controls the rows which are kept by cutoff (others are shaded)"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$brushSlider, { cutoffs <- list() cutoffs["Sepal.Length"] <- list(list(input$brushSlider)) parallelPlot::setCutoffs("parPlot", cutoffs) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( sliderInput("brushSlider", "Brush for 'Sepal.Length' column:", min = 4, max = 8, step = 0.1, value = c(4, 8)), p("The slider controls the rows which are kept by cutoff (others are shaded)"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$brushSlider, { cutoffs <- list() cutoffs["Sepal.Length"] <- list(list(input$brushSlider)) parallelPlot::setCutoffs("parPlot", cutoffs) }) } shinyApp(ui, server) }
Tells which columns have to be displayed with histograms.
setHistoVisibility(id, histoVisibility)
setHistoVisibility(id, histoVisibility)
id |
output variable to read from (id which references the requested plot) |
histoVisibility |
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(parallelPlot) ui <- fluidPage( checkboxInput("histCB", "Histogram Visibility", FALSE), p("The check box controls the visibility of histograms"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$histCB, { histoVisibility <- rep(input$histCB, ncol(iris)) parallelPlot::setHistoVisibility("parPlot", histoVisibility) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( checkboxInput("histCB", "Histogram Visibility", FALSE), p("The check box controls the visibility of histograms"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$histCB, { histoVisibility <- rep(input$histCB, ncol(iris)) parallelPlot::setHistoVisibility("parPlot", histoVisibility) }) } shinyApp(ui, server) }
Tells which axes have to be displayed with an inverted orientation.
setInvertedAxes(id, invertedAxes)
setInvertedAxes(id, invertedAxes)
id |
output variable to read from (id which references the requested plot) |
invertedAxes |
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(parallelPlot) ui <- fluidPage( checkboxInput("orientationCB", "Axis orientation", FALSE), p("The check box controls the orientation of axes"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$orientationCB, { invertedAxes <- rep(input$orientationCB, ncol(iris)) parallelPlot::setInvertedAxes("parPlot", invertedAxes) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( checkboxInput("orientationCB", "Axis orientation", FALSE), p("The check box controls the orientation of axes"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(iris) }) observeEvent(input$orientationCB, { invertedAxes <- rep(input$orientationCB, ncol(iris)) parallelPlot::setInvertedAxes("parPlot", invertedAxes) }) } 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(parallelPlot) ui <- fluidPage( checkboxInput("hideColumnsCB", "Hide last columns", FALSE), p("The check box controls the visibility of the two last columns"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(mtcars) }) observeEvent(input$hideColumnsCB, { keptColumns <- vapply( 1:ncol(mtcars), function(i) { return(ifelse(input$hideColumnsCB, ncol(mtcars) - i >= 2, TRUE)) }, logical(1) ) parallelPlot::setKeptColumns("parPlot", keptColumns) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( checkboxInput("hideColumnsCB", "Hide last columns", FALSE), p("The check box controls the visibility of the two last columns"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ parallelPlot(mtcars) }) observeEvent(input$hideColumnsCB, { keptColumns <- vapply( 1:ncol(mtcars), function(i) { return(ifelse(input$hideColumnsCB, ncol(mtcars) - i >= 2, TRUE)) }, logical(1) ) parallelPlot::setKeptColumns("parPlot", keptColumns) }) } shinyApp(ui, server) }
Tells which column is used to determine the color to attribute to each row.
setRefColumnDim(id, dim)
setRefColumnDim(id, dim)
id |
output variable to read from (id which references the requested plot) |
dim |
Name of the reference column (used to determine the color to attribute to a row);
|
No return value, called from shiny applications for side effects.
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "refColumnDimSelect", "Reference column:", choices = list( "None" = 1, "First" = 2, "Second" = 3 ), selected = "None" ), p("Selector controls the colomn used to determine the color to attribute to rows"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical) }) observeEvent(input$refColumnDimSelect, { choice <- as.numeric(input$refColumnDimSelect) refColumnDim <- list(NULL, colnames(mtcars)[1], colnames(mtcars)[2])[[choice]] parallelPlot::setRefColumnDim("parPlot", refColumnDim) }) } shinyApp(ui, server) }
if(interactive() && require(shiny)) { library(shiny) library(parallelPlot) ui <- fluidPage( selectInput( "refColumnDimSelect", "Reference column:", choices = list( "None" = 1, "First" = 2, "Second" = 3 ), selected = "None" ), p("Selector controls the colomn used to determine the color to attribute to rows"), parallelPlotOutput("parPlot") ) server <- function(input, output, session) { output$parPlot <- renderParallelPlot({ categorical <- list(cyl = c(4, 6, 8), vs = c(0, 1), am = c(0, 1), gear = 3:5, carb = 1:8) parallelPlot(mtcars, categorical = categorical) }) observeEvent(input$refColumnDimSelect, { choice <- as.numeric(input$refColumnDimSelect) refColumnDim <- list(NULL, colnames(mtcars)[1], colnames(mtcars)[2])[[choice]] parallelPlot::setRefColumnDim("parPlot", refColumnDim) }) } shinyApp(ui, server) }