ys_add_labels | R Documentation |
This is commonly done prior to saving data to SASxport or other formats that will track label metadata for a data column.
ys_add_labels(data, spec, fun = label.ycol, strict = TRUE)
data |
a |
spec |
yspec object for |
fun |
the function to use for forming |
strict |
if |
By default, an error is generated when the column names of the data set
are not identical to the column names in the spec. Set strict = FALSE
to
bypass this error and label only columns that are in common between data
and 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.
spec <- ys_help$spec()
data <- ys_help$data()
data <- ys_add_labels(data, spec)
sapply(data, attr, "label")
str(data[,1:5])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.