Collection of functions dealing with labelled data, like reading and writing data between R and other statistical software packages like 'SPSS', 'SAS' or 'Stata', and working with labelled data. This includes easy ways to get, set or change value and variable label attributes, to convert labelled vectors into factors or numeric (and vice versa), or to deal with multiple declared missing values.
This package contains utility functions that are useful when working with labelled data (especially intended for people coming from 'SPSS', 'SAS' or 'Stata' and/or who are new to R).
Basically, this package covers reading and writing data between other statistical packages (like 'SPSS') and R, based on the haven and foreign packages; hence, this package also includes functions to make working with labelled data easier. This includes easy ways to get, set or change value and variable label attributes, to convert labelled vectors into factors or numeric (and vice versa), or to deal with multiple declared missing values.
To install the latest development snapshot (see latest changes below), type following commands into the R console:
To install the latest stable release from CRAN, type following command into the R console:
In case you want / have to cite my package, please use
citation('sjlabelled') for citation information.
set_na(), to define (labelled)
NA-values in a vector.
keep.labels-argument. With this, users can easily convert vector to factors and vice versa, preserving label-attributes.
val_labels()as counterpart to
var_labels(), to set value labels, with support for quasi-quotation (see Examples).
var_labels()now supports quasi-quotation (see Examples).
haven_labelledfrom the haven-package.
get_term_labels()that returned wrong object names for factors where factor levels did start with "1".
var_labels(), where non-existing columns may lead to wrong labelling.
copy_labels()now also copy labels even if columns in subsetted and original data frame do not completely match.
get_labels()are renamed to shorter versions
include.valueswill become softly deprecated.
read_*()-functions get a
verbose-argument, to show or hide the progressbar when imported datasets are converted.
get_term_labels()now support clmm-objects (package ordinal) and stanmvreg-objects (package rstanarm).
enc-argument for character encoding, which is now supported since haven 1.1.2.
NULLfor unsupported models, instead of giving an error.
get_dv_labels()now returns a default string for unsupported models, instead of giving an error.
as_labelled()now corrects inconsistent types between labels and variable values.
multi.resp-argument to return each label of a multivariate response model (only for brmsfit objects).
get_label()now also returns name-attribute for empty labels if
xwas a data.frame.
write_*()-functions should now properly set labels for negative values.
get_note(), because there is already an R base function for this purpose:
prefix-argument to prefix the returned labels of categorical variable either with the related variable name or label.
get_term_labels()for models that used unlabelled data in combination with other contrasts than the default option.
get_dv_labels()no longer returns
"NULL"for multivariate-response-models fitted with brms.
lbl_df(), because printing tibbles now depends on pkg pillar and was revised substantially, so maintainace of
lbl_df()is too extensive.
dplyr::select_helperswere updated to
convert_case()from call to package snakecase
clm-objects from package ordinal,
polr-objects from package MASS and
Zelig-relogit-objects from package Zelig.
...-argument to pass down further arguments to
convert_case()is now exported, for usage in other packages as well.
protect-argument from internal case conversion (affects
get_dv_labels()), in preparation for forthcoming snakecase-package update.
lbl_df()due to changes in the internals of
as_factor()to convert labelled vectors into factors, preserving labels.
brmsfit-objects from package
get_term_labels()now includes variable names for factors with numeric factor levels only (and not only return the numeric level as term label).
xwas a character vector and argument
sjlabelledno longer requires R version 3.3.3 or higher.
case-argument, to convert labels into any case, using the snakecase-package.
get_dv_labels()to retrieve term labels from regression models.
use.labels-argument to use value labels as new values if these are numeric.