pd_tbl: A table to query with dplyr

View source: R/tbl.R

pd_tblR Documentation

A table to query with dplyr

Description

Attaches a version's DuckDB file with [pd_connect()] and returns one of its tables or views as a lazy 'dplyr' table. Verbs such as 'filter()', ‘group_by()' and 'summarise()' are translated to SQL and run by ’DuckDB' over HTTPS, reading only the blocks they need; 'collect()' brings the result into R. Calls for the same dataset and version share one connection.

Usage

pd_tbl(slug, table = NULL, version = NULL, cache = NULL)

Arguments

slug

The dataset's slug, as in its page URL 'https://publicdata.au/d/<slug>/'.

table

The table or view to query. A dataset that is one table has one, 'records', which is the default; for a database such as G-NAF, name one of [pd_tables()] or a view such as '"address_view"'.

version

A version date from [pd_versions()]. The newest when 'NULL'.

cache

Download the whole file into [pd_cache_dir()] once and attach it from there, which makes repeated scans of a large database much faster. Off unless 'options(publicdataau.cache = TRUE)' is set.

Value

A lazy table from 'dbplyr'. Its connection is 'dbplyr::remote_con(x)', which carries the same '"publicdata"' attribute as [pd_connect()].

See Also

Other query: filters, pd_aggregate(), pd_connect(), pd_rows()

Examples


library(dplyr)
pd_tbl("au-road-deaths") |>
  filter(year >= 2020) |>
  count(state) |>
  collect()


publicdataau documentation built on Oct. 14, 2026, 5:07 p.m.