setRefColumnDim | R Documentation |
Tells which column is used to determine the color to attribute to each row.
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)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.