Skip to contents

Extracts notes stored in a dataset's attributes and organizes them into a tidy data frame. This function is particularly useful for processing Stata datasets imported into R that contain variable notes in their attributes.

Usage

lpr_extract_notes(data)

Arguments

data

A dataset (data frame) containing notes in its attributes. The notes should be stored as a list where each element is a vector of length 3 containing: (1) variable name, (2) note ID, and (3) note text.

Value

A data frame with three columns:

variable_name

Name of the variable the note belongs to

note_id

Identifier for the note

note_value

The actual note text

Details

This function processes the attributes of a dataset to extract notes that are typically stored in a specific format. It skips any notes associated with "_dta" (dataset-level notes) and only returns variable-specific notes. The function expects the notes to be organized as a list where each element contains exactly three components: variable name, note ID, and note value.

Examples

# Extract the notes
if (FALSE) { # \dontrun{
notes <- lpr_extract_notes(df)
print(notes)} # }