vazul is an R package for analyis blinding in research contexts. It offers two main approaches to anonymize data while preserving analytical validity: masking (replacing values with anonymous labels) and scrambling (randomizing the order of existing values).
Analysis Blinding Approaches
Masking replaces original values with anonymous labels, completely hiding the original information:
treatment <- c("control", "treatment", "control")
mask_labels(treatment)
#> "masked_group_01" "masked_group_02" "masked_group_01"Scrambling preserves all original values but randomizes their order:
scramble_values(treatment)
#> "treatment" "control" "control" # Same values, different orderInstallation
You can install the released version of vazul from CRAN with:
install.packages("vazul")Or the development version from GitHub with:
remotes::install_github("nthun/vazul")Functions
Masking Functions
Replace categorical values with anonymous labels to completely hide original information.
mask_labels() - Mask vector values
library(vazul)
# Basic masking
treatment <- c("control", "treatment", "control", "treatment")
set.seed(123)
mask_labels(treatment)
#> "masked_group_01" "masked_group_02" "masked_group_01" "masked_group_02"
# Custom prefix
mask_labels(treatment, prefix = "group_")
#> "group_01" "group_02" "group_01" "group_02"
mask_variables() - Mask data frame columns
df <- data.frame(
condition = c("A", "B", "A", "B"),
treatment = c("ctrl", "test", "ctrl", "test"),
score = c(85, 92, 78, 88)
)
# Mask multiple columns
mask_variables(df, c("condition", "treatment"))
# Use tidyselect helpers
mask_variables(df, where(is.character))The .across_variables parameter allows for consistent masking across multiple columns (e.g., longitudinal data in wide format).
df <- data.frame(
wave_1 = c("A", "B", "A"),
wave_2 = c("B", "A", "B"),
score = c(10, 20, 30)
)
# Mask across variables consistently
mask_variables(df, starts_with("wave_"), .across_variables = TRUE)Scrambling Functions
Randomize the order of values while preserving the original data content.
scramble_values() - Scramble vector order
# Numeric data
set.seed(123)
scramble_values(1:5)
#> [1] 3 2 5 4 1
# Categorical data
scramble_values(c("A", "B", "C", "A", "B"))
#> [1] "B" "A" "C" "B" "A"
scramble_variables() - Scramble data frame columns
df <- data.frame(x = 1:6, group = rep(c("A", "B"), each = 3))
# Scramble across entire column
scramble_variables(df, "x")
# Scramble within groups
scramble_variables(df, "x", .groups = "group")
# Using dplyr grouping
library(dplyr)
df |> group_by(group) |> scramble_variables("x")Row-wise scrambling: Use .byrow = TRUE to shuffle values within each row across the selected columns.
df_items <- data.frame(
item1 = c(1, 4, 7),
item2 = c(2, 5, 8),
item3 = c(3, 6, 9)
)
# Shuffles values horizontally within each row
scramble_variables(df_items, item1:item3, .byrow = TRUE)Datasets
The vazul package includes two research datasets for demonstration and practice.
MARP Dataset
The marp dataset contains cross-national survey data on religiosity: 10,535 participants across 24 countries studying religiosity and well-being (Hoogeveen, Sarafoglou, van Elk, & Wagenmakers, 2022a).
Williams Dataset
The williams dataset contains experimental data from the large-scale direct replication of the stereotyping study by Williams, Sng, and Neuberg (2016), released by Holzmeister et al. (2024).
Dataset References
- Hoogeveen, S., Sarafoglou, A., van Elk, M., & Wagenmakers, E.-J. (2022a). A many-analysts approach to the relation between religiosity and well-being: The dataset. PsyArXiv. https://doi.org/10.31234/osf.io/dpex6
- Holzmeister, F., Camerer, C., Chen, Y., Dreber, A., Hoogeveen, S., Huber, J., … Waldén, V. (2024, November 19). Data and Analysis. Retrieved from osf.io/47drs
- Williams, K. E. G., Sng, O., & Neuberg, S. L. (2016). Ecology-driven stereotypes override race stereotypes. Proceedings of the National Academy of Sciences, 113(2), 310–315. https://doi.org/10.1073/pnas.1519401113
Explanation of the package name
Vazul was a Hungarian prince in the 11. century. He was blinded by the king to become unfit for the throne. More info: https://en.wikipedia.org/wiki/Vazul
Documentation
- Function help:
?mask_labels,?scramble_values, etc. - Package website: https://nthun.github.io/vazul/
Authors
-
Tamás Nagy - Package author and maintainer
- Márton Kovács - Author
- Alexandra Sarafoglou - Data contributor and author
Citation
Nagy, T., Kovács, M., & Sarafoglou, A. (2026). vazul: An R package for analysis blinding. Zenodo. https://doi.org/10.5281/zenodo.18269711
License
MIT License - see LICENSE file for details.
