This function generates an interactive HTML table (codebook) for a dataset, showing variable names, labels, and value labels extracted from attributes.
Usage
make_codebook(d, config = NULL, page = 25, save = FALSE)
codebook(d, config = NULL, page = 25, save = FALSE)Arguments
- d
A data frame, typically imported with
havenor similar, where variables havelabelandlabelsattributes.- config
Path to a YAML config file. Needed if dataset has not been imported with
havenand value labels are not stored as attributes.- page
Integer. Number of rows to display per page in the interactive table. Default is 25.
- save
Logical value. Default is FALSE
Value
A DT::datatable object that can be rendered in R Markdown or Shiny
or a stand alone HTML file.
Details
The value labels are displayed on separate lines using HTML <br> tags.
To ensure these tags are rendered correctly, the argument escape = FALSE
is passed to DT::datatable(). Without this, HTML tags would be shown as
plain text instead of creating line breaks.
The table includes:
Column filters for easy searching.
Export buttons (Copy, CSV, Excel, PDF, Print).
