Skip to contents

The attribution metadata entries of all tables from parquet_tbl() that a lazy table or collected data was read from (see parquet_sources()) as one string, e.g. for the caption of a plot of joined data.

Usage

parquet_sources_attribution(
  x,
  sep = " | ",
  language = getOption("r2parquet.language")
)

Arguments

x

a lazy DuckDB table, e.g. from parquet_tbl() and joins of such tables, or data collected with collect_parquet().

sep

separator between attributions that don't get combined.

language

language code like "fr" for the attributions in that language (attribution_fr, falling back to attribution), or NULL for the plain ones, see parquet_sources(). Defaults, like parquet_sources(), to the language a lazy table's columns were selected in, else to the r2parquet.language option.

Value

a string, or NULL if none of the sources has an attribution, which leaves out a caption passed to ggplot2::labs().

Details

Repeated attributions appear once. Attributions that differ only in their last word get combined: "Statistics Canada Product ldb_000b21f_e" and "Statistics Canada Product 2021_92-151_X" become "Statistics Canada Product ldb_000b21f_e, 2021_92-151_X", other attributions get separated by sep, in the order of the sources.

Examples

# \donttest{
if (requireNamespace("curl", quietly = TRUE) && curl::has_internet()) {
  census <- "https://data.mountainmath.ca/census/2021/"
  # the dissemination blocks of one dissemination area, with their population
  blocks <- parquet_tbl(paste0(census,"ldb_000b21f_e.parquet")) |>
    dplyr::filter(DAUID == "59150307") |>
    dplyr::select(DBUID,geometry)
  population <- parquet_tbl(paste0(census,"2021_92-151_X.parquet")) |>
    dplyr::select(DBUID,DBPOP2021)
  data <- collect_parquet(dplyr::inner_join(blocks,population,by="DBUID"))
  parquet_sources_attribution(data)
}
#> NULL
# }