Skip to main content
v2026.11,986 entries · CC-BY 4.0

Datawizard R Package: Data Wrangling & Stats Guide

A comprehensive guide to datawizard in R: lightweight data cleaning, reshaping, and statistical transformations for reproducible empirical research pipelines.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

The datawizard R package is an open-source statistical utility developed within the easystats ecosystem to streamline data preparation, data wrangling, and statistical transformations for empirical researchers. Engineered with a minimalist dependency structure—relying solely on base R and the insight core package—datawizard delivers high-performance, string-friendly functions for common data manipulation tasks such as filtering, reshaping, selecting, recoding, robust standardization, and exploratory distribution summaries without introducing complex tidy evaluation overhead or namespace collisions.

What it is used for in research

In empirical research workflows across the social, behavioural, biomedical, and life sciences, data preparation consumes a substantial proportion of an investigator’s analytical timeline. Raw observational datasets, experimental logs, clinical trials, and survey exports rarely arrive in the rectangular, standardized formats required by statistical modeling routines. Researchers frequently encounter messy variable names, inconsistent coding schemes, missing values, reversed psychometric scales, and unstandardized continuous measurements that undermine reproducibility and introduce human error.

The datawizard package was conceived by the easystats collaborative team—a collective dedicated to making statistical analysis and reporting in R intuitive, transparent, and reproducible. While existing toolsets such as the dplyr package in R and tidyr offer expressive grammars for data manipulation, they depend on an extensive network of tidyverse dependencies and non-standard evaluation (NSE) rules governed by rlang. For researchers developing standalone analytical scripts, simulation packages, or reproducible research compendia, this dependency footprint can lead to installation fragility, namespace masking, and programming friction when writing custom wrapper functions.

datawizard solves these challenges by providing two foundational pillars of data preparation in a single, lightweight package:

  • Data Wrangling and Manipulation: Offering intuitive functions with a standardized data_* prefix—such as data_filter(), data_select(), data_modify(), data_rename(), data_relocate(), and data_to_long()—that mirror modern data science workflows while accepting both unquoted column symbols and quoted character strings natively.
  • Statistical Transformations and Preprocessing: Bridging the historical divide between general-purpose data wrangling and formal statistical modeling by offering dedicated routines for parametric and robust standardization (standardize()), centering (center()), normalization (normalize()), rank transformations (ranktransform()), winsorization (winsorize()), and comprehensive distributional audits (describe_distribution()).

By integrating seamlessly with downstream modeling packages in the easystats suite—including parameters for model summary tables, performance for goodness-of-fit metrics, and effectsize for standardized effect indices—datawizard serves as the standardized data processing backend for reproducible quantitative research.

How to install or access it

Researchers can install datawizard directly from official CRAN repositories or obtain development builds from the project’s official mirrors. The package requires R version 4.0 or higher. Because datawizard restricts its hard imports to insight (≥ 1.5.4), stats, and utils, installation is exceptionally fast and avoids recursive compilation of heavy C++ dependencies.

To install the stable release from CRAN, execute the following command in your R console or RStudio environment:

install.packages("datawizard")

Investigators seeking the full analytical capabilities of the easystats ecosystem can install the unified bundle, which includes datawizard alongside complementary tools for Bayesian analysis, model evaluation, and reporting:

install.packages("easystats")

For research teams requiring bleeding-edge bug fixes, experimental verbs, or patches prior to CRAN submission, the development version is hosted continuously on the easystats R-universe build server and GitHub. To install from R-universe without external compilation tools, specify the repository URL:

install.packages("datawizard", repos = c("https://easystats.r-universe.dev", "https://cloud.r-project.org"))

Alternatively, if you maintain a local development toolchain using the devtools R package or remotes, install directly from the official source repository on GitHub:

remotes::install_github("easystats/datawizard")

Once installation finishes, verify the loaded version and confirm that no namespace conflicts exist with your current workspace:

library(datawizard)
packageVersion("datawizard")

Step-by-step instructions

To illustrate a rigorous empirical workflow, consider an investigator preprocessing a multi-wave observational research study. The raw dataset contains participant identifiers, demographic covariates, multi-item psychometric Likert responses, and physiological biomarkers measured across two experimental conditions (Baseline and Follow-up). The following numbered procedure demonstrates how to clean, reshape, transform, and verify this dataset using exact datawizard functions.

Step 1: Inspect structural distribution properties and data health. Before modifying any variables, compute a comprehensive summary of central tendency, dispersion, skewness, kurtosis, and missingness across all continuous variables using describe_distribution():

# Load libraries and initialize illustrative empirical research frame
library(datawizard)

# Inspect structural distribution metrics
summary_stats <- describe_distribution(study_data)
print(summary_stats)

This diagnostic step reveals whether biomarkers exhibit severe positive skewness or kurtosis, allowing the investigator to decide whether parametric or robust statistical transformations are required.

Step 2: Filter invalid records and remove empty observations. Clean the dataset by removing empty rows, dropping empty columns, and filtering out participants who failed inclusion criteria (e.g., age under 18 or negative response latencies):

# Remove empty rows and empty columns
clean_data <- remove_empty(study_data)

# Filter valid records using logical conditions
clean_data = 18 & reaction_time > 0)

data_filter() accepts standard R logical operators (&, |) or comma-separated expressions, matching the filtering intuition of base R subset() while preserving data frame attributes.

Step 3: Select and rename analytical variables with string-friendly syntax. Retain only the variables necessary for the statistical model, and standardize column naming conventions:

# Extract variables using column selection helpers
selected_data <- data_select(
  clean_data,
  select = c("subject_id", "group", starts_with("item_"), "biomarker_t1", "biomarker_t2")
)

# Rename columns using vector mappings
selected_data <- data_rename(
  selected_data,
  pattern = c("biomarker_t1", "biomarker_t2"),
  replacement = c("cortisol_baseline", "cortisol_followup")
)

Unlike packages requiring tidy evaluation quoting, data_select() and data_rename() accept character vectors seamlessly, making them ideal for automated batch processing.

Step 4: Recode categorical factors and reverse psychometric survey scales. Survey items often require scale inversion so that higher numerical values consistently denote higher levels of the psychological construct:

# Reverse Likert items measured on a 1-to-5 scale
selected_data <- data_reverse(
  selected_data,
  select = c("item_2", "item_4"),
  range = c(1, 5)
)

# Recode categorical treatment groups
selected_data <- data_recode(
  selected_data,
  select = "group",
  recodes = list("Control" = c("ctrl", "C"), "Treatment" = c("trt", "T"))
)

Step 5: Reshape repeated measures from wide to long format. Longitudinal and repeated-measures analyses—such as mixed-effects models or pairwise hypothesis evaluations in t.test in RStudio—require data in tidy long format:

# Convert wide repeated cortisol measurements to tidy long format
long_data <- data_to_long(
  selected_data,
  select = c("cortisol_baseline", "cortisol_followup"),
  names_to = "time_point",
  values_to = "cortisol_level",
  id_cols = "subject_id"
)

data_to_long() automatically extracts time-point designations into a single factor column while preserving all participant-level covariates.

Step 6: Standardize continuous predictors using parametric or robust methods. Transform raw physiological measurements into unitless z-scores to improve regression interpretability and facilitate numerical convergence in generalized linear models:

# Standard parametric z-score standardization (mean = 0, SD = 1)
long_data <- data_modify(
  long_data,
  cortisol_z = standardize(cortisol_level)
)

# Robust standardization using median and median absolute deviation (MAD)
long_data <- data_modify(
  long_data,
  cortisol_robust_z = standardize(cortisol_level, robust = TRUE)
)

Step 7: Merge supplemental experimental metadata. Finally, join participant demographic tables or institutional site metadata into the master analytical file:

# Merge secondary clinical metadata by participant ID
final_analytical_frame <- data_merge(
  long_data,
  site_metadata,
  by = "subject_id",
  join = "left"
)

Output and how to read it

Understanding how datawizard structures its outputs ensures that analysts can accurately report descriptive statistics in manuscripts and pass cleaned objects to statistical modeling engines. Each major function yields structured, transparent data objects.

When invoking describe_distribution(), the returned object is a specialized summary data frame carrying detailed distribution metrics for each continuous column:

  • Variable: The exact column name evaluated.
  • Mean and SD: The arithmetic mean and sample standard deviation, providing baseline parametric moments.
  • IQR: The interquartile range (75th percentile minus 25th percentile), serving as a non-parametric measure of statistical dispersion.
  • Range: The minimum and maximum boundaries displayed as [min, max], immediately highlighting out-of-bounds coding anomalies or recording errors.
  • Skewness: Fisher-Pearson standardized skewness coefficient. Values between -0.5 and +0.5 indicate approximately symmetric distributions; magnitudes exceeding ±1.0 signal substantial asymmetry requiring robust estimation, rank transformations, or logarithmic adjustment.
  • Kurtosis: Excess kurtosis relative to the normal distribution (where normal kurtosis = 0). Positive values indicate leptokurtic distributions with heavy tails and outlier propensity; negative values indicate platykurtic, light-tailed distributions.
  • n and n_Missing: The count of valid observed values and the absolute number of NA missing cases.

When applying standardize(), continuous variables are transformed so that their central moment is zero. In normal parametric standardization (default), the function computes (x – μ) / σ, yielding values representing standard deviations from the sample mean. In robust standardization (robust = TRUE), the transformation computes (x – median) / (1.4826 × MAD), centering the distribution on the sample median and scaling by the median absolute deviation. This robust transformation prevents extreme physiological or behavioral outliers from artificially shrinking the variance of the non-outlying majority.

When executing reshaping operations via data_to_long(), the output remains a clean, standard R data.frame. It does not introduce specialized tibble subclasses or hidden grouping attributes that can unexpectedly alter downstream base R functions like subset() or split().

Troubleshooting

When deploying datawizard across heterogeneous research datasets, investigators may encounter specific operational challenges. Below are common error states, diagnostic checks, and verified solutions based on package documentation:

1. Attribute preservation and factor collisions with labelled survey data. Survey data imported from SPSS, Stata, or SAS via haven frequently carry haven_labelled S3 classes and variable label attributes. When applying mathematical transformations like standardize() directly to labelled vectors, older R routines may throw warnings or strip attributes. In datawizard, use to_numeric() or to_factor() prior to transformation to explicitly handle value labels and establish consistent numeric scales.

2. Missing value propagation during statistical standardization. By default, standardize() calculates the mean and standard deviation after omitting missing values (na.rm = TRUE), placing NA entries in the exact index positions of missing inputs. If a researcher passes a vector consisting entirely of NA values or zero variance (standard deviation equal to 0), the standardized output returns NaN. Check for zero-variance constants before standardization using describe_distribution().

3. Distinguishing data frame extraction from atomic vector extraction. A frequent conceptual confusion arises between data_select() and data_extract(). data_select() always returns a data frame, even when selecting a single column. Conversely, data_extract() extracts the column as a pure atomic vector (equivalent to dplyr::pull() or base R df[[col]]). Passing the output of data_select() into statistical functions expecting a vector (such as stats::t.test()) will cause an input error.

4. Programmatic column selection in automated loops and functions. When writing custom functions where column names are passed as character variables, researchers accustomed to dplyr often struggle with tidy evaluation mechanics (such as {{ var }} or .data[[var]]). In datawizard, no special quoting syntax is required: pass character vectors directly into the select argument: data_select(df, select = my_variable_vector).

5. Resolving package masking and function conflicts. Although datawizard prefixes its data manipulation verbs with data_* specifically to prevent namespace collisions with dplyr, general statistical helper functions like standardize() or normalize() may overlap with functions from packages like robustHD, bbmle, or vegan. To guarantee exact execution without ambiguity, call the function with its explicit namespace prefix: datawizard::standardize().

Free alternatives

While datawizard provides an exceptional combination of lightweight dependencies and specialized statistical transformations, empirical researchers possess multiple open-source alternatives within the R ecosystem. Selecting the optimal tool depends on data volume, pipeline complexity, and dependency constraints.

Package Primary Architecture Hard Dependencies String-Friendly API Statistical Transformations Best Research Use Case
datawizard Base R and insight S3 1 (insight) Full native support Built-in (z-score, robust MAD, Gelman 2-SD, winsorize) Empirical modeling, psychology/social science workflows, lightweight package development
dplyr / tidyr Tidyverse C++ (cpp11) 15+ (rlang, vctrs, etc.) Requires across() / rlang External (requires custom mutate expressions) General data science, complex multi-table pipelines, tidyverse-native environments
data.table High-performance C and OpenMP 0 (pure C runtime) Native character expressions Manual (via in-place ‘:=’ updates) High-frequency microdata, large clinical biobanks, massive tabular datasets (>10 GB)
collapse C / C++ optimized backend 1 (Rcpp) Formulas and vectors Advanced (fscale, fbetween, fwithin) Econometric panel data, complex grouping operations, ultra-fast vector math
base R Core R distribution 0 (standard distribution) Native character indexing Standard (scale, sweep, aggregate) Minimalist environments, zero-dependency scripting, base teaching curricula

The data table below compares technical parameters, CRAN release versions, dependency counts, and architectural paradigms across these packages in full detail, providing reproducible reference specifications for quantitative software evaluation.

Frequently asked questions

What is the difference between datawizard and dplyr?

While both packages accomplish tabular data manipulation, datawizard is explicitly designed to have minimal dependencies (importing only insight and base R) and features a consistent data_* prefix that accepts plain character strings without requiring tidy evaluation. In contrast, dplyr relies on a substantial dependency hierarchy within the tidyverse and requires non-standard evaluation mechanics for programmatic column selection.

Does datawizard require the tidyverse to be installed?

No. datawizard does not depend on, import, or require any tidyverse packages. It is intentionally engineered as a lightweight, zero-heavy-dependency package that runs on a clean installation of base R with only the insight package installed.

How does robust standardization in datawizard differ from standard z-scoring?

Standard z-score standardization computes deviations from the sample mean divided by the sample standard deviation, which can be heavily skewed by extreme outliers. Robust standardization (invoked with standardize(x, robust = TRUE)) centers the variable around the sample median and divides by the median absolute deviation (MAD multiplied by 1.4826), providing an outlier-resistant scale transformation.

Can datawizard handle labelled data imported from SPSS or Stata?

Yes. datawizard includes dedicated functions such as to_numeric(), to_factor(), and data_recode() that process and respect variable labels and value attributes imported from SPSS, Stata, and SAS datasets via the haven package.

Researchers should cite the formal software publication: Patil, I., Makowski, D., Ben-Shachar, M. S., Wiernik, B. M., Bacher, E., and Lüdecke, D. (2022). datawizard: An R Package for Easy Data Preparation and Statistical Transformations. Journal of Open Source Software, 7(78), 4684. https://doi.org/10.21105/joss.04684.

How does data_to_long differ from tidyr pivot_longer?

data_to_long() provides a direct, string-friendly alternative to pivot_longer() that operates without the tidyselect dependency stack. It accepts character vectors directly in its select argument and returns a standard R data frame without attaching custom tibble S3 classes.

Sources

  • CRAN Package Repository: datawizard — https://cran.r-project.org/package=datawizard (accessed 2026-11-15)
  • Journal of Open Source Software: Patil et al. (2022) — https://doi.org/10.21105/joss.04684 (accessed 2026-11-15)
  • easystats Documentation: datawizard Project Reference and Vignettes — https://easystats.github.io/datawizard/ (accessed 2026-11-15)
  • GitHub Development Repository: easystats/datawizard — https://github.com/easystats/datawizard (accessed 2026-11-15)

Data: R Data Wrangling and Transformation Libraries Technical Comparison

Technical specifications, dependency footprints, and statistical preprocessing capabilities across R data manipulation libraries compiled from CRAN package indexes and official documentation.

Period covered: 2026. Coverage: Global.

R Data Wrangling and Transformation Libraries Technical Comparison
LibraryCRAN Release Version (version)Direct Hard Dependencies (count)Native String ArgumentsStatistical TransformationsReshaping VerbExecution Engine
datawizard1.5.01Native (strings and unquoted)Comprehensive (standardize, robust MAD, Gelman 2-SD, winsorize)data_to_long()Base R and C++ via insight
dplyr1.1.49Requires rlang / across()Basic (via external stats functions)None (delegates to tidyr)C++ via cpp11 and R
tidyr1.3.18Requires rlang / tidyselectNone (focused strictly on rectangular reshaping)pivot_longer()C++ via cpp11 and R
data.table1.16.40Native character expressionsBasic (fast roll, lead/lag, in-place scaling)melt()C and OpenMP multithreading
collapse2.0.191Native (symbols, character vectors, and formulas)High-performance (fscale, fbetween, fwithin)pivot()C / C++ optimized backend
base R4.4.20Native character indexing and subsettingStandard (scale, sweep, summary)reshape()C and Fortran core runtime

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Datawizard R Package: Data Wrangling & Stats Guide

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →