Skip to contents

Generates a standardized Data Guide File (DGF) including variable names, labels, descriptions, data types, factor levels, conversion rules, and summary statistics. Optionally reads a CSV/Excel file if a filename is provided instead of a data frame.

Usage

create_dgf(
  df,
  vtypes = NULL,
  use.df.types = FALSE,
  guess.factors = TRUE,
  guess.dates = FALSE,
  dd = NULL,
  vname = NULL,
  vlabel = NULL,
  vdesc = NULL,
  vtype = NULL,
  vconvert = NULL,
  vformat = NULL,
  vname_alias = NULL,
  keep.dd.cols = NULL,
  preview_dd = F,
  preview_dp = F,
  file = "DGF"
)

Arguments

df

A data frame to generate the DGF from, or a character string specifying the path to a CSV file.

vtypes

Optional named vector specifying variable types.

use.df.types

Logical; if `TRUE`, preserves original data frame types.

guess.factors

Logical; if `TRUE`, attempts to convert character variables to factors.

guess.dates

Logical; if `TRUE`, attempts to convert columns to dates.

dd

Optional additional data dictionary information.

vname, vlabel, vdesc, vtype, vconvert, vformat, vname_alias

Optional vectors providing variable names, labels, descriptions, types, conversion functions, formats, and aliases.

keep.dd.cols

Optional vector of column names to retain from an existing data dictionary.

preview_dd, preview_dp

Logical; controls previewing of data dictionary or data preview.

file

Character string specifying the base name for output files (without extension). Defaults to `"DGF"`.

Value

A data frame representing the Data Guide File (DGF) with all metadata, statistics, and summary information. DGF is saved as csv and xlsx files in the current working directory.

Details

See dgf and dgf.detailed data sets for examples of how to use this funciton.