Skip to contents

Reads a documentation sheet from an Excel file and extracts variable descriptions and coding information.

Usage

dataDescription(fn, sheet = "Description")

Arguments

fn

character string. Path to the Excel file.

sheet

character string. Name of the documentation sheet. Default is "Description".

Value

a list with the following components:

  • desctable: A data frame containing the description table.

  • codes: A named list of code definitions per variable.

Details

The function reads the specified sheet and trims trailing empty rows.

If a column named "Codes" is present, its contents are split by line breaks and returned as a list of codes per variable, keyed by the "Variable" column.

The Excel sheet is expected to contain at least:

  • Variable names

  • Descriptions

  • Optional coding definitions

If the sheet does not exist or no additional sheets are present, the function returns NULL.

See also

Other label.import: openDataObject()

Examples

if (FALSE) { # \dontrun{
desc <- dataDescription("example.xlsx")

desc$desctable
desc$codes[["gender"]]
} # }