ys_add_labels: Add label attribute to data set columns

View source: R/class-yspec.R

ys_add_labelsR Documentation

Add label attribute to data set columns

Description

Add label attribute to data set columns

Usage

ys_add_labels(data, spec, fun = label.ycol)

Arguments

data

a data.frame to label

spec

yspec object for data

fun

the function to use for forming label

Details

An error is generated if the names of data are not identical to names of spec.

If the user passes fun to generate a custom label, the function must take a single argument, the column ycol object, and must return the label for that column as a character vector of length one.

Examples

spec <- ys_help$spec()

data <- ys_help$data()

data <- ys_add_labels(data,spec)

sapply(data,attr,"label")

str(data[,1:5])


metrumresearchgroup/yspec documentation built on May 24, 2024, 12:48 a.m.