The examples on this page will use an in-memory DuckDB database loaded with data. Multiple datasets are used and the page is organized by the dataset being analyzed.
library(rsgl)
#>
#> Attaching package: 'rsgl'
#> The following objects are masked from 'package:datasets':
#>
#> cars, trees
library(duckdb)
#> Loading required package: DBI
con <- dbConnect(duckdb())
#> duckdb keeps downloaded extensions and secrets in a temporary directory:
#> ℹ /tmp/RtmpGTP8NG/duckdb
#> This is removed when the R session ends.
#> • Extensions are re-downloaded each session.
#> • Secrets are lost.
#> ℹ Run duckdb(shared_home = TRUE) (or create ~/.duckdb) to keep them (suitable for most users).
#> ℹ Run duckdb(shared_home = FALSE) to accept the temporary directory (and silence this message).
#> ℹ See ?duckdb_storage for details and alternatives.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)
")dbGetPlot(con, "
visualize
count(*) as theta,
origin as color
from cars
group by
origin
using bars
title
theta as 'Number of Cars',
color as 'Country of Origin'
")dbGetPlot(con, "
visualize
bin(miles_per_gallon) as x,
count(*) as y
from cars
group by
bin(miles_per_gallon)
using bars
")dbGetPlot(con, "
visualize
origin as x,
miles_per_gallon as y
from cars
using boxes
scale by
log(y)
")