| pd_tbl | R Documentation |
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.
pd_tbl(slug, table = NULL, version = NULL, cache = NULL)
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. |
A lazy table from 'dbplyr'. Its connection is 'dbplyr::remote_con(x)', which carries the same '"publicdata"' attribute as [pd_connect()].
Other query:
filters,
pd_aggregate(),
pd_connect(),
pd_rows()
library(dplyr)
pd_tbl("au-road-deaths") |>
filter(year >= 2020) |>
count(state) |>
collect()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.