Learn R Programming

metatools (version 0.1.6)

set_variable_labels: Apply labels to a data frame using a metacore object

Description

This function leverages metadata available in a metacore object to apply labels to a data frame.

Usage

set_variable_labels(data, metacore, dataset_name = NULL)

Value

Dataframe with labels applied

Arguments

data

A dataframe or tibble upon which labels will be applied

metacore

metacore object that contains the specifications for the dataset of interest.

dataset_name

Optional string to specify the dataset. This is only needed if the metacore object provided hasn't already been subsetted.

Examples

Run this code

mc <- metacore::spec_to_metacore(
        metacore::metacore_example("p21_mock.xlsx"),
        quiet=TRUE
        )
dm <- haven::read_xpt(metatools_example("dm.xpt"))
set_variable_labels(dm, mc, dataset_name = "DM")

Run the code above in your browser using DataLab