Render ggsql visualizations in a Shiny application. renderGgsql() accepts
either a ggsql query string or a Spec object (returned by
ggsql_execute()). When given a string, it validates and executes the query
against reader.
Usage
ggsqlOutput(outputId, width = "100%", height = "400px")
renderGgsql(expr, reader = NULL, env = parent.frame(), quoted = FALSE)Arguments
- outputId
Output variable to read from.
- width, height
CSS dimensions for the output container.
- expr
An expression that returns a ggsql query string or a
Specobject. Strings may containr:varnamereferences that resolve variables from the expression's local scope (see Examples).- reader
A
Readerobject created byduckdb_reader(). WhenNULL(the default), the session reader set byggsql_session_reader()is used.- env
The environment in which to evaluate
expr.- quoted
Logical. Is
expra quoted expression?
Examples
if (FALSE) { # interactive() && requireNamespace("shiny", quietly = TRUE)
library(shiny)
ui <- fluidPage(
ggsqlOutput("chart")
)
server <- function(input, output, session) {
ggsql_session_reader(duckdb_reader())
output$chart <- renderGgsql({
"SELECT * FROM r:mtcars VISUALISE mpg AS x, disp AS y DRAW point"
})
}
shinyApp(ui, server)
}
