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

The functions of sjmisc are designed to work together seamlessly with other packes from the tidyverse, like dplyr. For instance, you can use the functions from sjmisc both within a pipe-worklflow to manipulate data frames, or to create new variables with mutate(). See vignette("design_philosophy", "sjmisc") for more details.

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("strengejacke/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

32,088

Version

2.4.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Lüdecke

Last Published

April 7th, 2017

Functions in sjmisc (2.4.0)

drop_labels

Drop, add or convert (non-)labelled values
zap_na_tags

Convert tagged NA values into regular NA
copy_labels

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

Frequency table of tagged NA values
add_columns

Add or replace data frame columns
%nin%

Value matching
group_str

Group near elements of string vectors
add_labels

Add, replace or remove value labels of variables
find_var

Find variable by name or label
is_labelled

Check whether object is of class "labelled"
descr

Basic descriptive statistics
dicho

Dichotomize variables
frq

Frequencies of labelled variables
is_num_fac

Check whether a factor has numeric levels only
replace_na

Replace NA with specific values
to_factor

Convert variable into factor and keep value labels
get_label

Retrieve variable label(s) of labelled data
group_var

Recode numeric variables into equal-ranged groups
is_crossed

Check whether two factors are crossed or nested
set_label

Add variable label(s) to variables
flat_table

Flat (proportional) tables
lbl_df

Create a labelled data frame
merge_df

Merge labelled data frames
set_labels

Add value labels to variables
sjmisc-package

Data Transformation and Labelled Data Utility Functions
split_var

Split numeric variables into smaller groups
set_na

Replace specific values in vector with NA
set_note

Add notes (annotations) to (labelled) variables
write_spss

Write data to other statistical software packages
zap_inf

Convert infiite or NaN values into regular NA
to_label

Convert variable into factor with associated value labels
efc

Sample dataset from the EUROFAMCARE project
empty_cols

Return or remove variables or observations that are completely missing
get_note

Retrieve notes (annotations) from labelled variables
row_sums

Row sums and means for data frames
spread_coef

Spread model coefficients of list-variables into columns
std

Standardize and center variables
var_rename

Rename variables
get_labels

Retrieve value labels of labelled data
get_na

Retrieve tagged NA values of labelled variables
ref_lvl

Change reference level of (numeric) factors
remove_all_labels

Remove value and variable labels from vector or data frame
str_contains

Check if string contains pattern
str_pos

Find partial matching and close distance elements in strings
word_wrap

Insert line breaks in long labels
as_labelled

Convert vector to labelled class
big_mark

Formats large numbers with big marks
is_empty

Check whether string, list or vector is empty
to_long

Convert wide data to long format
to_value

Convert factors to numeric variables
is_even

Check whether value is even or odd
recode_to

Recode variable categories into new values
reexports

Objects exported from other packages
merge_imputations

Merges multiple imputed data frames into a single data frame
trim

Trim leading and trailing whitespaces from strings
to_dummy

Split (categorical) vectors into dummy variables