Output and render functions for using lollipop() within Shiny applications
and interactive R Markdown / Quarto documents.
Usage
lollipopOutput(output_id, width = "100%", height = "440px")
renderLollipop(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 a
lollipop()widget.- env
The environment in which to evaluate
expr.- quoted
Is
expralready quoted? Defaults toFALSE.
Value
lollipopOutput() returns a Shiny output UI element;
renderLollipop() returns a Shiny render function.
Examples
if (interactive() && requireNamespace("shiny", quietly = TRUE)) {
ui <- shiny::fluidPage(lollipopOutput("lp"))
server <- function(input, output) {
output$lp <- renderLollipop({
variants <- data.frame(
position = c(100, 250, 400),
count = c(12, 5, 3),
label = c("A", "B", "C")
)
lollipop(variants, length = 500)
})
}
shiny::shinyApp(ui, server)
}