Learn R Programming

labelled

This package is built on the new classes haven_labelled and haven_labelled_spss introduced by haven package to handle labelled variables imported from SPSS, Stata and SAS. The labelled package propose several functions to manipulate such vectors and their metadata: variable labels, value labels and user-defined missing values.

Installation & Documentation

To install stable version:

install.packages("labelled")

Documentation of stable version: https://larmarange.github.io/labelled/

To install development version:

remotes::install_github("larmarange/labelled")

Documentation of development version: https://larmarange.github.io/labelled/dev/

Introduction

Read the vignette at https://larmarange.github.io/labelled/articles/intro_labelled.html

Cheatsheet

Some general guidelines

  1. Functions are intended to support labelled metadata structures only. However, to_labelled() method allows to convert metadata from foreign and memisc packages.
  2. Functions should, by default, modify metadata only (i.e. classes and attributes), except if explicitly expressed by the user.

Copy Link

Version

Install

install.packages('labelled')

Monthly Downloads

51,476

Version

2.14.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Joseph Larmarange

Last Published

January 8th, 2025

Functions in labelled (2.14.0)

to_labelled

Convert to labelled data
recode_if

Recode some values based on condition
update_variable_labels_with

Update variable/value labels with a function
val_labels

Get / Set value labels
nolabel_to_na

Recode values with no label to NA
to_character

Convert input to a character vector
update_labelled

Update labelled data to last version
recode.haven_labelled

Recode values
tagged_na_to_user_na

Convert tagged NAs into user NAs
sort_val_labels

Sort value labels
reexports

Objects exported from other packages
remove_attributes

Remove attributes
val_labels_to_na

Recode value labels to NA
remove_labels

Remove variable label, value labels and user defined missing values
var_label

Get / Set a variable label
copy_labels

Copy variable and value labels and SPSS-style missing value
names_prefixed_by_values

Turn a named vector into a vector of names prefixed by values
na_values

Get / Set SPSS missing values
look_for

Look for keywords variable names and descriptions / Create a data dictionary
is_prefixed

Check if a factor is prefixed
drop_unused_value_labels

Drop unused value labels
to_factor

Convert input to a factor.
unique_tagged_na

Unique elements, duplicated, ordering and sorting with tagged NAs
x_haven_2.0

Datasets for testing