Learn R Programming

⚠️There's a newer version (2.14.0) of this package.Take me there.

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

From CRAN:

install.packages("labelled")

Latest version from GitHub:

devtools::install_github("larmarange/labelled")

Introduction to labelled

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

Breaking changes introduced in version 2.0.0

Following version 2.0.0 of haven, labelled() and labelled_spss() now produce objects with class “haven_labelled” and “haven_labelled_spss”, due to conflict between the previous “labelled” class and the “labelled” class used by Hmisc.

A new function update_labelled() could be used to convert data imported with an older version of haven to the new classes.

Some general principles

  1. Functions are intented to support haven_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

77,755

Version

2.3.1

License

GPL-3

Maintainer

Joseph Larmarange

Last Published

April 29th, 2020

Functions in labelled (2.3.1)

mean.haven_labelled

Arithmetic mean for numeric labelled vectors
val_labels_to_na

Recode value labels to NA
copy_labels

Copy variable and value labels and SPSS style missing value
nolabel_to_na

Recode values with no label to NA
labelled

Create a labelled vector.
recode.haven_labelled

Recode values
to_labelled

Convert to labelled data
look_for

Look for keywords variable names and descriptions
labelled_spss

Create a labelled vector with SPSS style of missing values.
to_character

Convert input to a character vector
remove_attributes

Remove attributes
remove_labels

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

Get / Set a variable label
to_factor

Convert input to a factor.
tagged_na

"Tagged" missing values
sort_val_labels

Sort value labels
update_labelled

Update labelled data to version 2.0.0
na_values

Get / Set SPSS missing values
val_labels

Get / Set value labels