parcoords-shiny: Shiny bindings for 'parcoords'

Description Usage Arguments Examples

Description

Output and render functions for using sunburst within Shiny applications and interactive Rmd documents.

Usage

1
2
3
parcoordsOutput(outputId, width = "100%", height = "400px")

renderParcoords(expr, env = parent.frame(), quoted = FALSE)

Arguments

outputId

output variable to read from

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

expr

An expression that generates a sunburst

env

The environment in which to evaluate expr.

quoted

Is expr a quoted expression (with quote()). This is useful if you want to save an expression in a variable.

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
if(interactive()) {
  #### filter proxy example ----

  library(parcoords)
  library(shiny)

  ui <- tagList(
    textOutput("filteredstate", container=h3),
    parcoordsOutput("pc")
  )

  server <- function(input, output, session) {
    rv <- reactiveValues(filtered = FALSE)

    output$pc <- renderParcoords({
      parcoords(mtcars)
    })

    observe({
      # toggle between filtered and unfiltered every 2.5 seconds
      invalidateLater(2500)
      rv$filtered <- !isolate(rv$filtered)
    })

    observeEvent(rv$filtered, {
      # create a proxy with which we will communicate between
      #   Shiny and the parallel coordinates without a re-render
      pcp <- parcoordsProxy("pc")

      if(rv$filtered) {
        pcFilter(
          pcp,
          list(
            cyl = c(6,8),
            hp = list(gt = 200)
          )
        )
      } else {
        pcFilter(pcp, list())
      }
    })

    output$filteredstate <- renderText({
      paste0("Filtered: ", rv$filtered)
    })
  }

  shinyApp(ui = ui, server = server)

  ### center proxy example ----
  library(shiny)
  library(parcoords)

  ui <- tags$div(
    parcoordsOutput("pc", width = 2500),
    style="width: 2500px;"
  )

  server <- function(input, output, session) {
    # create a proxy with which we will communicate between
    #   Shiny and the parallel coordinates without a re-render
    pcp <- parcoordsProxy("pc")

    output$pc <- renderParcoords({
      parcoords(mtcars)
    })

    pcCenter(pcp, 'drat')
  }

  shinyApp(ui=ui, server=server)

  ### hide/unhide proxy example ----
  library(parcoords)
  library(shiny)

  ui <- tagList(
    selectizeInput(
      inputId = "columns",
      label = "Columns to Hide",
      choices = c("names",colnames(mtcars)),
      selected = "names",
      multiple = TRUE
    ),
    parcoordsOutput("pc"),
    checkboxInput("hidenames", label="Hide Row Names", value=TRUE),
    parcoordsOutput("pc2")
  )

  server <- function(input, output, session) {
    output$pc <- renderParcoords({
      parcoords(mtcars, rownames = FALSE, brushMode = "1d")
    })

    output$pc2 <- renderParcoords({
      parcoords(mtcars, rownames = FALSE)
    })

    pcUnhide

    observeEvent(input$columns, {
      # create a proxy with which we will communicate between
      #   Shiny and the parallel coordinates without a re-render
      pcp <- parcoordsProxy("pc")

      pcHide(pcp, input$columns)
    }, ignoreInit = TRUE, ignoreNULL = FALSE)

    observeEvent(input$hidenames, {
      # create a proxy with which we will communicate between
      #   Shiny and the parallel coordinates without a re-render
      pcp2 <- parcoordsProxy("pc2")
      if(input$hidenames) {
        pcHide(pcp2, "names")
      } else {
        pcUnhide(pcp2, "names")
      }
    })

  }

  shinyApp(ui = ui, server = server)


  ### snapshot example ----
  library(shiny)
  library(parcoords)

  ui <- tags$div(
    actionButton(inputId = "snapBtn", label = "snapshot"),
    parcoordsOutput("pc", height=400)
  )

  server <- function(input, output, session) {
    # create a proxy with which we will communicate between
    #   Shiny and the parallel coordinates without a re-render
    pcp <- parcoordsProxy("pc")

    output$pc <- renderParcoords({
      parcoords(mtcars)
    })

    observeEvent(input$snapBtn, {
      # create a proxy with which we will communicate between
      #   Shiny and the parallel coordinates without a re-render
      pcp <- parcoordsProxy("pc")
      pcSnapshot(pcp)
    })
  }

  shinyApp(ui=ui, server=server)
}

Example output



parcoords documentation built on May 24, 2019, 5:06 p.m.