Manipulating Labelled Data

Work with labelled data imported from 'SPSS' or 'Stata' with 'haven' or 'foreign'. This package provides useful functions to deal with "haven_labelled" and "haven_labelled_spss" classes introduced by 'haven' package.


Project Status: Active - The project has reached a stable, usablestate and is being activelydeveloped. Travis-CI BuildStatus CRAN_Status_Badge Rdoc Downloads DOI

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 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.

News

labelled 2.2.0

  • new function copy_labels_from(), compliant with dplyr syntax
  • update_labelled() is now more strict (#42 by @iago-pssjd)
  • new functions look_for() and lookfor() imported from questionr (#44)
  • new unlist option for var_label()
  • tagged_na() and similar functions are now imported from haven

labelled 2.1.0

  • var_label(), applied to a data.frame, now accepts a character vector of same length as the number of columns.
  • set_variable_labels has a new .labels argument.
  • New unclass option in to_factor(), to be used when strict = TRUE (#36)
  • Following haven version 2.1.0, it is not mandatory anymore to define a value label before defining a SPSS style missing value. labelled_spss(), na_values() and na_range() have been updated accordingly (#37)

labelled 2.0.2

  • to_factor() bug fix then applied on a data.frame (#33)

labelled 2.0.1

  • update_labelled() bug fix then applied on a data.frame (#31)

labelled 2.0.0

BREAKING CHANGE

  • 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.

Other changes

  • user_na_to_na option added to to_factor()
  • foreign_to_labelled() now import SPSS missing values (#27)
  • a strict argument added to to_factor() (#25)
  • remove_attributes() preserve character vectors (#30)

labelled 1.1.0

  • extend dplyr::recode() method to be compatible with labelled vectors.
  • copy_labels() now copy also na_range and na_values attributes.
  • new method remove_attributes()

labelled 1.0.1

  • bug fix: argument drop_unused_labels could now be used with to_factor.data.frame()
  • new labels argument for to_labelled() method when applied to a factor
  • bug fix: appropriate column names with data.frame (#20)

labelled 1.0.0

  • now imports haven
  • new function to deal with user defined missing values (SPSS style): na_values(), na_range(), set_na_values(), set_na_values(), remove_user_na(), user_na_to_na().
  • remove_labels() has been updated.

labelled 0.2.3

  • new functions set_variable_labels(), set_value_labels(), add_value_labels() and remove_value_labels() compatible with %>%.
  • new functions remove_val_labels and remove_var_label().
  • bug fix in to_character.labelled() when applied to data frames.

labelled 0.2.2

  • to_factor(), to_character() and to_labelled.factor() now preserves variable label.
  • bug fix in to_factor() when applied to data frames.

labelled 0.2.0

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("labelled")

2.2.1 by Joseph Larmarange, 2 months ago


http://larmarange.github.io/labelled/


Report a bug at https://github.com/larmarange/labelled/issues


Browse source code at https://github.com/cran/labelled


Authors: Joseph Larmarange [aut, cre] , Daniel Ludecke [ctb] , Hadley Wickham [ctb] , Bojanowski Michal [ctb] , Briatte François [ctb]


Documentation:   PDF Manual  


GPL-3 license


Imports haven, dplyr, stats

Suggests testthat, knitr, rmarkdown, questionr, snakecase

Enhances memisc


Imported by SEERaBomb, codebook, crosswalkr, jsmodule, jstable, questionr, tableone, tidyqwi.


See at CRAN