attr_to_factor: Convert object with attributes in "map" to factor

View source: R/attr_to_factor.R

attr_to_factorR Documentation

Convert object with attributes in "map" to factor

Description

Used to extract texts from a variable containing numeric values.

Usage

attr_to_factor(x)

Arguments

x

Object with "map" attributes, where levels and labels exist

Value

Factor

Examples

df <- data.frame(cars = 1:3)
attr(df$cars, "map") <-
  data.frame(levels = 1:3, labels = c("Volvo", "Saab", "Opel"))
  attr_to_factor(df$cars)

swehip/slrplotfun documentation built on Oct. 25, 2022, 10:50 a.m.