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 or basic statistical tests, performing common recode and data transformation tasks or working with labelled data (especially intended for people coming from 'SPSS' and/or who are new to R).

Basically, this package covers four 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 used statistical tests and computation of statistical coefficients, or at least convenient wrappers for such test functions
  • frequently applied recoding and variable transformation tasks

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

32,088

Version

1.8

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Lüdecke

Last Published

May 19th, 2016

Functions in sjmisc (1.8)

drop_labels

Drop labels of zero-count values
is_nested

Check whether two factors are nested
read_sas

Import SAS dataset as data frame into R
deff

Design effects for two-level mixed models
std_beta

Standardized Beta coefficients and CI of lm and mixed models
cv

Coefficient of Variation
efc

Sample dataset from the EUROFAMCARE project
add_labels

Add value labels to variables
cramer

Cramer's V for a contingency table
is_even

Check whether value is even
table_values

Expected and relative table values
get_label

Retrieve variable label(s) of labelled data
merge_df

Merge labelled data frames
group_labels

Create labels for recoded groups
get_re_var

Random effect variances
get_note

Retrieve notes (annotations) from labelled variables
to_value

Convert factors to numeric variables
get_values

Retrieve values of labelled variables
is_odd

Check whether value is odd
to_factor

Convert variable into factor and keep value labels
recode_to

Recode variable categories into new values
icc

Intraclass-Correlation Coefficient
get_na_flags

Retrieve missing value flags of labelled variables
chisq_gof

Chi-square goodness-of-fit-test
smpsize_lmm

Sample size for linear mixed models
cod

Tjur's Coefficient of Discrimination
str_contains

Check if string contains pattern
set_label

Add variable label(s) to variables
rmse

Root Mean Squared Error (RMSE)
is_num_fac

Check whether a factor has numeric levels only
cronb

Cronbach's Alpha for a matrix or data frame
get_na

Retrieve missing values of labelled variables
group_str

Group near elements of string vectors
to_dummy

Split (categorical) vectors into dummy variables
group_var

Recode numeric variables into equal-ranged groups
phi

Phi value for contingency tables
converge_ok

Convergence test for mixed effects models
weight2

Weight a variable
get_labels

Retrieve value labels of labelled data
mean_n

Row means with min amount of valid values
is_empty

Check whether string or vector is empty
zap_labels

Convert labelled values into NA
rec_pattern

Create recode pattern for 'rec' function
set_note

Add notes (annotations) to (labelled) variables
is_crossed

Check whether two factors are crossed
read_stata

Import STATA dataset as data frame into R
as_labelled

Convert vector to labelled class
is_labelled

Check whether object is of class "labelled"
wtd_sd

Weighted standard deviation for variables
write_spss

Write content of data frame to SPSS sav-file
dicho

Dichotomize variables
unlabel

Convert labelled vectors into normal classes
word_wrap

Insert line breaks in long labels
r2

Compute R-squared of (generalized) linear (mixed) models
levene_test

Plot Levene-Test for One-Way-Anova
read_spss

Import SPSS dataset as data frame into R
set_na

Set NA for specific variable values
frq

Summary of labelled vectors
ref_lvl

Change reference level of (numeric) factors
write_stata

Write content of data frame to STATA dta-file
copy_labels

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

Remove value labels from variables
sjmisc-package

Data Transformation and Labelled Data Utility Functions
se

Standard Error for variables
weight

Weight a variable
overdisp

Check overdispersion of GL(M)M's
zap_unlabelled

Convert non-labelled values into NA
to_long

Convert wide data to long format
remove_all_labels

Remove value and variable labels from vector or data frame
rec

Recode variables
split_var

Split numeric variables into smaller groups
replace_na

Replace NA with specific values
eta_sq

Eta-squared of fitted anova
re_var

Random effect variances
fill_labels

Add missing value labels to partially labelled vector
str_pos

Find partial matching and close distance elements in strings
get_frq

Get summary of labelled vectors
hoslem_gof

Hosmer-Lemeshow Goodness-of-fit-test
wtd_se

Weighted standard error for variables
mic

Mean Inter-Item-Correlation
mwu

Mann-Whitney-U-Test
set_labels

Add value labels to variables
reliab_test

Performs a reliability test on an item scale
to_label

Convert variable into factor and replaces values with associated value labels
trim

Trim leading and trailing whitespaces from strings
labelled

Create a labelled vector
lbl_df

Create a labelled data frame
to_na

Convert missing values of labelled variables into NA