
Utility functions for visualization specifications
spec_utility.RdThese functions allow you to extract various information from a Spec object
returned by ggsql_execute().
Usage
ggsql_metadata(spec)
ggsql_sql(spec)
ggsql_visual(spec)
ggsql_layer_count(spec)
ggsql_layer_data(spec, index = 1L)
ggsql_stat_data(spec, index = 1L)
ggsql_layer_sql(spec, index = 1L)
ggsql_stat_sql(spec, index = 1L)
ggsql_warnings(spec)Arguments
- spec
A
Specobject as returned byggsql_execute()- index
Layer index
Value
ggsql_metadata: A list with elementsrows,columns, andlayer_countggsql_sql: A character string with the SQL portion of the queryggsql_visual: A character string with the visual portion of the queryggsql_layer_count: An integer giving the number of layersggsql_layer_data: A data frame, orNULLif no data is available for this layerggsql_stat_data: A data frame, orNULLif the layer doesn't use a stat transformggsql_layer_sql: A character string with the SQL query used by the layer to fetch its data, orNULLif the layer doesn't have any data.ggsql_stat_sql: A character string with the SQL query used by the layers stat transform, orNULLif the layer doesn't have a stat transform.ggsql_warnings: A data.frame with columnsmessage,line, andcolumngiving the validation warnings for the spec
Examples
reader <- duckdb_reader()
ggsql_register(reader, mtcars, "cars")
spec <- ggsql_execute(reader,
"SELECT * FROM cars VISUALISE mpg AS x DRAW histogram"
)
ggsql_metadata(spec)
#> $rows
#> [1] 17
#>
#> $columns
#> [1] "stroke" "pos1" "pos1end" "opacity" "pos2" "fill" "pos2end"
#>
#> $layer_count
#> [1] 1
#>
ggsql_visual(spec)
#> [1] "VISUALISE mpg AS x DRAW histogram"