Skip to contents

Output and render functions for using upset() within Shiny applications and interactive R Markdown / Quarto documents.

Usage

upsetOutput(output_id, width = "100%", height = "520px")

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

Arguments

output_id

Output variable to read from.

width, height

Element size, passed to htmlwidgets::shinyWidgetOutput().

expr

An expression that generates an upset() widget.

env

The environment in which to evaluate expr.

quoted

Is expr already quoted? Defaults to FALSE.

Value

upsetOutput() returns a Shiny output UI element; renderUpset() returns a Shiny render function.

Examples

if (interactive() && requireNamespace("shiny", quietly = TRUE)) {
  sets <- list(A = c("x", "y", "z"), B = c("y", "z", "w"))
  # Elements x sets, with the set names as column names.
  elements <- unique(unlist(sets))
  m <- sapply(sets, function(s) elements %in% s)
  ix <- upset_intersections(m)
  ui <- shiny::fluidPage(upsetOutput("us"))
  server <- function(input, output) {
    output$us <- renderUpset({
      upset(data.frame(size = ix$size), sets = ix$sets,
            membership = ix$membership, set_sizes = ix$set_sizes,
            total = ix$total)
    })
  }
  shiny::shinyApp(ui, server)
}