--- title: "Example gallery" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Example gallery} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4.5 ) ``` ## Database Setup The examples on this page will use an in-memory [DuckDB](https://duckdb.org) database loaded with data. Multiple datasets are used and the page is organized by the dataset being analyzed. ```{r setup, warning = FALSE} library(rsgl) library(duckdb) con <- dbConnect(duckdb()) ``` ## Cars ### Setup ```{r} dbWriteTable(con, "cars", cars) dbGetQuery(con, " select * from cars limit 5 ") ``` ### Example Plots ```{r} dbGetPlot(con, " visualize horsepower as x, miles_per_gallon as y from cars using points ") ``` --- ```{r} dbGetPlot(con, " visualize horsepower as x, miles_per_gallon as y from cars using ( points layer regression line ) facet by origin scale by log(x), log(y) ") ``` --- ```{r} dbGetPlot(con, " visualize bin(miles_per_gallon) as x, count(*) as y from cars group by bin(miles_per_gallon) using bars ") ``` --- ```{r} dbGetPlot(con, " visualize origin as x, miles_per_gallon as y from cars using boxes scale by log(y) ") ``` ## Trees ### Setup ```{r} dbWriteTable(con, "trees", trees) dbGetQuery(con, " select * from trees limit 5 ") ``` ### Example Plots ```{r} dbGetPlot(con, " visualize age as x, circumference as y from trees collect by tree_id using lines ") ``` --- ```{r} dbGetPlot(con, " visualize age as theta, radius as r from ( select *, circumference/(2*pi()) as radius from trees ) collect by tree_id using lines ") ```