The duckdb R package implements the standard DBI interface. Run SQL and get data frames back, or use dplyr and let dbplyr translate your pipelines into SQL executed by DuckDB.
From R or RStudio.
install.packages(c("duckdb", "dplyr", "dbplyr", "ggplot2"))read_only = TRUE guarantees nothing gets modified.
library(duckdb)
con <- dbConnect(duckdb(), dbdir = "selfsync-db.duckdb", read_only = TRUE)
dbGetQuery(con, "FROM z_fit_session_mesgs LIMIT 5")dplyr verbs run inside DuckDB, only the result is collected into R. Here, the kilometres you ran each year.
library(dplyr)
library(ggplot2)
tbl(con, "z_fit_session_mesgs") |>
filter(z_sport == "running") |>
group_by(year = year(z_start_time)) |>
summarise(km = sum(z_total_distance, na.rm = TRUE) / 1000) |>
collect() |>
ggplot(aes(year, km)) +
geom_col()dbDisconnect(con, shutdown = TRUE) when you are done.180 / 2^31 to get degrees before drawing a map.Wondering what a table or a column holds? Browse the FIT file reference.