Learn R Programming

sjmisc (version 1.7)

lbl_df: Create a labelled data frame

Description

This method wraps a local data frame and adds a lbl_df class attribute. Printing a lbl_df-data frame is comparable to printing tbl_df objects, but the class information in the output is replaced by the variable label.

Usage

lbl_df(x)

Arguments

x
A data frame.

Value

  • x, with lbl_df class-attribute.

Examples

Run this code
data(efc)
library(dplyr)
mydf <- lbl_df(efc %>%
  select(e15relat, e16sex, e17age) %>%
  slice(1:3))

mydf

# or...
mydf <- efc %>%
  select(e15relat, e16sex, e17age) %>%
  slice(1:3)

lbl_df(mydf)


mydf <- lbl_df(efc %>%
  select(e15relat, e16sex, e17age) %>%
  to_label() %>%
  set_label(c("Relationship", "Elder's gender", "Elder's age")))

mydf

Run the code above in your browser using DataLab