Skip to contents

Write an IVT table to Parquet

Usage

ivt_write_parquet(
  x,
  path = NULL,
  labels = TRUE,
  members = TRUE,
  dim_names = c("slug", "label"),
  language = "en",
  ...
)

Arguments

x

An ivt object from read_ivt().

path

Output .parquet path. Defaults to <product_id>.parquet in the data cache (ivt_cache_dir("data"), i.e. option canivt.data_cache or tempdir() when unset).

labels

Passed to ivt_tidy(): write labelled columns (TRUE, default) or the compact integer-id table (FALSE).

members

Also write the member-level table (ivt_members()) as a <name>_members.parquet sidecar next to path (TRUE, default), so collect_ivt() can convert dimension columns to full-level factors.

dim_names

How to name the data-dimension columns (passed to ivt_tidy() and the member sidecar): "slug" (default, the terse structural slug) or "label" (the full dimension name). Slug columns can be labelled on read with label_ivt_columns().

language

Output language for labels and label-derived column names (passed to ivt_tidy()): "en" (default) or "fr". The member sidecar carries both languages regardless.

...

Passed to arrow::write_parquet().

Value

path, invisibly.

Examples

path <- system.file("extdata", "98100044.ivt", package = "canivt")
ivt <- read_ivt(path)
if (requireNamespace("arrow", quietly = TRUE)) {
  out <- ivt_write_parquet(ivt, file.path(tempdir(), "98100044.parquet"))
  file.exists(out)
}
#> [1] TRUE