Learn R Programming

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

sjmisc - Data Transformation and Labelled Data Utility Functions

This package contains utility functions that are useful when carrying out data analysis, performing common recode and data transformation tasks or 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 three domains of functionality:

  • 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
  • frequently applied recoding and variable transformation tasks, also with support for labelled data

Installation

Latest development build

To install the latest development snapshot (see latest changes below), type following commands into the R console:

library(devtools)
devtools::install_github("sjPlot/sjmisc")

Officiale, stable release

     

To install the latest stable release from CRAN, type following command into the R console:

install.packages("sjmisc")

References, documentation and examples

Citation

In case you want / have to cite my package, please use citation('sjmisc') for citation information.

Copy Link

Version

Install

install.packages('sjmisc')

Monthly Downloads

34,037

Version

2.0.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Lüdecke

Last Published

October 31st, 2016

Functions in sjmisc (2.0.1)

drop_labels

Drop labels of zero-count values
fill_labels

Add missing value labels to partially labelled vector
as_labelled

Convert vector to labelled class
count_na

Frequency table of tagged NA values
copy_labels

Copy value and variable labels to (subsetted) data frames
efc

Sample dataset from the EUROFAMCARE project
empty_cols

Return or remove variables or observations that are completely missing
add_labels

Add or replace value labels of variables
dicho

Dichotomize variables
big_mark

Formats large numbers with big marks
get_values

Retrieve values of labelled variables
get_na

Retrieve tagged NA values of labelled variables
flat_table

Flat (proportional) tables
group_var

Recode numeric variables into equal-ranged groups
get_labels

Retrieve value labels of labelled data
get_note

Retrieve notes (annotations) from labelled variables
group_labels

Create labels for recoded groups
frq

Frequencies of labelled variables
get_label

Retrieve variable label(s) of labelled data
group_str

Group near elements of string vectors
is_odd

Check whether value is odd
is_even

Check whether value is even
merge_df

Merge labelled data frames
is_crossed

Check whether two factors are crossed
merge_imputations

Merges multiple imputed data frames into a single data frame
is_nested

Check whether two factors are nested
is_num_fac

Check whether a factor has numeric levels only
lbl_df

Create a labelled data frame
is_empty

Check whether string or vector is empty
is_labelled

Check whether object is of class "labelled"
read_stata

Import STATA dataset as data frame into R
ref_lvl

Change reference level of (numeric) factors
read_spss

Import SPSS dataset as data frame into R
read_sas

Import SAS dataset as data frame into R
remove_all_labels

Remove value and variable labels from vector or data frame
rec

Recode variables
rec_pattern

Create recode pattern for 'rec' function
recode_to

Recode variable categories into new values
remove_labels

Remove value labels from variables
replace_na

Replace NA with specific values
to_character

Convert variable into character vector and replace values with associated value labels
set_na

Replace specific values in vector with NA
str_contains

Check if string contains pattern
set_label

Add variable label(s) to variables
set_note

Add notes (annotations) to (labelled) variables
sjmisc-package

Data Transformation and Labelled Data Utility Functions
split_var

Split numeric variables into smaller groups
str_pos

Find partial matching and close distance elements in strings
spread_coef

Spread model coefficients of list-variables into columns
set_labels

Add value labels to variables
to_dummy

Split (categorical) vectors into dummy variables
write_spss

Write content of data frame to SPSS sav-file
write_sas

Write content of data frame to SAS-file
to_factor

Convert variable into factor and keep value labels
unlabel

Convert labelled vectors into normal classes
word_wrap

Insert line breaks in long labels
to_label

Convert variable into factor and replace values with associated value labels
to_long

Convert wide data to long format
to_value

Convert factors to numeric variables
trim

Trim leading and trailing whitespaces from strings
zap_na_tags

Convert tagged NA values into regular NA
zap_unlabelled

Convert non-labelled values into NA
zap_labels

Convert labelled values into NA
write_stata

Write content of data frame to STATA dta-file