Learn R Programming

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

sjmisc - Data and Variable Transformation Functions

Collection of miscellaneous utility functions, supporting data transformation tasks like recoding, dichotomizing or grouping variables, setting and replacing missing values. The data transformation functions also support 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")

Please note the package dependencies when installing from GitHub. The GitHub version of this package may depend on latest GitHub versions of my other packages, so you may need to install those first, if you encounter any problems. Here's the order for installing packages from GitHub:

sjlabelledsjmiscsjstatsggeffectssjPlot

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

A cheatsheet can be downloaded from here (PDF) or from the RStudio cheatsheet collection.

For more examples, see package vignettes (browseVignettes("sjmisc")).

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

26,286

Version

2.7.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Lüdecke

Last Published

March 25th, 2018

Functions in sjmisc (2.7.1)

all_na

Check if vector only has NA values
descr

Basic descriptive statistics
add_columns

Add or replace data frame columns
find_var

Find variable by name or label
efc

Sample dataset from the EUROFAMCARE project
dicho

Dichotomize variables
flat_table

Flat (proportional) tables
empty_cols

Return or remove variables or observations that are completely missing
count_na

Frequency table of tagged NA values
frq

Frequencies of labelled variables
is_crossed

Check whether two factors are crossed or nested
is_even

Check whether value is even or odd
big_mark

Formats large numbers with big marks
%nin%

Value matching
is_empty

Check whether string, list or vector is empty
group_var

Recode numeric variables into equal-ranged groups
is_float

Check if a variable is of (non-integer) double type or a whole number
group_str

Group near elements of string vectors
is_num_fac

Check whether a factor has numeric levels only
rec

Recode variables
row_count

Count row or column indices
merge_imputations

Merges multiple imputed data frames into a single data frame
merge_df

Merge labelled data frames
reexports

Objects exported from other packages
rec_pattern

Create recode pattern for 'rec' function
ref_lvl

Change reference level of (numeric) factors
rotate_df

Rotate a data frame
recode_to

Recode variable categories into new values
remove_var

Remove variables from a data frame
replace_na

Replace NA with specific values
str_start

Find start and end index of pattern in string
set_na

Replace specific values in vector with NA
split_var

Split numeric variables into smaller groups
str_pos

Find partial matching and close distance elements in strings
std

Standardize and center variables
shorten_string

Shorten character strings
sjmisc-package

Data and Variable Transformation Functions
spread_coef

Spread model coefficients of list-variables into columns
str_contains

Check if string contains pattern
row_sums

Row sums and means for data frames
to_character

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

Convert variable into factor with associated value labels
word_wrap

Insert line breaks in long labels
to_dummy

Split (categorical) vectors into dummy variables
trim

Trim leading and trailing whitespaces from strings
var_rename

Rename variables
to_long

Convert wide data to long format
to_factor

Convert variable into factor and keep value labels
to_value

Convert factors to numeric variables
var_type

Determine variable type
zap_inf

Convert infiite or NaN values into regular NA