Skip to contents

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

Usage

embeddingOutput(output_id, width = "100%", height = "480px")

renderEmbedding(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 embedding() widget.

env

The environment in which to evaluate expr.

quoted

Is expr already quoted? Defaults to FALSE.

Value

embeddingOutput() returns a Shiny output UI element; renderEmbedding() returns a Shiny render function.

Details

In a Shiny app the lasso selection is pushed back to the server as input$<output_id>_selected, a 0-based integer vector of the selected rows (so embeddingOutput("umap") populates input$umap_selected). It updates on every completed selection and is NULL until the first one.

Examples

if (interactive() && requireNamespace("shiny", quietly = TRUE)) {
  ui <- fluidPage(embeddingOutput("emb"))
  server <- function(input, output) {
    output$emb <- renderEmbedding({
      embedding(data.frame(x = rnorm(200), y = rnorm(200)))
    })
  }
  shinyApp(ui, server)
}