dict: Create an HTML data dictionary

View source: R/data-edit.R

dictR Documentation

Create an HTML data dictionary

Description

Creates a dictionary from an explicit data frame or active R4VN data.

Usage

dict(
  ...,
  data = NULL,
  describe = TRUE,
  file = NULL,
  title = "Data dictionary",
  open = TRUE
)

Arguments

...

Optional variable selectors. For backward compatibility, an explicit data frame may be supplied first.

data

Optional explicit data frame. When omitted, active data is used.

describe

Logical; include compact descriptive summaries.

file

Output HTML file.

title

Dictionary title.

open

Logical; open the generated file.

Value

The HTML path invisibly.

Examples

d <- data.frame(sex = c(1, 2), age = c(20, NA))
usedf(d, quiet = TRUE)
path <- dict(file = tempfile(fileext = ".html"), open = FALSE)
file.exists(path)

# Extended usage examples

d <- data.frame(sex = c(1, 2, 1), age = c(20, 30, NA), bmi = c(21, 24, 26))
labvar(d, sex, label = "Sex", values = c("1" = "Male", "2" = "Female"))
labvar(d, age, label = "Age in years")

# Dictionary for every variable
f1 <- dict(d, file = tempfile(fileext = ".html"), open = FALSE)

# Dictionary for selected variables
f2 <- dict(d, sex, age, file = tempfile(fileext = ".html"), open = FALSE)

# Omit descriptive summaries
f3 <- dict(d, describe = FALSE, file = tempfile(fileext = ".html"), open = FALSE)

# Active-data syntax
usedf(d, quiet = TRUE)
f4 <- dict(file = tempfile(fileext = ".html"), open = FALSE)


R4VN documentation built on Sept. 30, 2026, 5:13 p.m.