Learn R Programming

parallelPlot (version 0.4.0)

setRefColumnDim: Line coloring

Description

Tells which column is used to determine the color to attribute to each row.

Usage

setRefColumnDim(id, dim)

Value

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

Arguments

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); NULL is allowed, meaning there is no coloring to apply.

Examples

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

Run the code above in your browser using DataLab