Learn R Programming

sjlabelled (version 1.1.7)

label_to_colnames: Use variable labels as column names

Description

This function sets variable labels as column names, to use "labelled data" also for those functions that cannot cope with labelled data by default.

Usage

label_to_colnames(x)

Arguments

x

A data frame.

Value

x with variable labels as column names. For variables without variable labels, the column name is left unchanged.

Examples

Run this code
# NOT RUN {
data(iris)

iris <- var_labels(
  iris,
  Petal.Length = "Petal length (cm)",
  Petal.Width = "Petal width (cm)"
)

colnames(iris)
plot(iris)

colnames(label_to_colnames(iris))
plot(label_to_colnames(iris))
# }

Run the code above in your browser using DataLab