Learn R Programming

mariposa

Professional statistical analysis for survey data in R.

mariposa (Marburg Initiative for Political and Social Analysis) provides 80 functions for importing, managing, transforming, and analyzing survey data. Covers the full workflow from data import (SPSS, Stata, SAS, Excel) through label management, recoding, and standardization to statistical analysis with survey weights, grouped operations via dplyr::group_by(), and publication-ready output. Statistical results are validated against SPSS v29 within documented per-tier tolerances; see vignette("spss-compatibility") for per-function status.

Installation

# Install from GitHub
devtools::install_github("YannickDiehl/mariposa")

Quick Start

library(mariposa)
library(dplyr)

# Load example survey data (2,500 respondents)
data(survey_data)

# Interactive HTML codebook in RStudio Viewer
codebook(survey_data)

# Descriptive statistics with survey weights
survey_data %>%
  describe(age, income, life_satisfaction, weights = sampling_weight)

# Frequency table
survey_data %>%
  frequency(education, weights = sampling_weight)

# Compare groups with t-test
survey_data %>%
  t_test(life_satisfaction, group = gender, weights = sampling_weight)

# Detailed SPSS-style output with summary()
survey_data %>%
  t_test(life_satisfaction, group = gender, weights = sampling_weight) %>%
  summary()

# Scale analysis workflow
reliability(survey_data, trust_government, trust_media, trust_science) %>%
  summary()    # item statistics, inter-item correlations

survey_data <- survey_data %>%
  mutate(m_trust = row_means(., trust_government, trust_media, trust_science))

# Regression
survey_data %>%
  linear_regression(life_satisfaction ~ age + income, weights = sampling_weight) %>%
  summary()    # coefficients, ANOVA table, diagnostics

Core Features

Statistical Functions

CategoryFunctionsPurpose
Data Importread_spss(), read_stata(), read_sas(), read_xlsx(), + 2 moreImport SPSS, Stata, SAS, and Excel with tagged NA support
Data Exportwrite_spss(), write_stata(), write_xpt(), write_xlsx()Export with full label and missing value roundtripping
Label Managementvar_label(), val_labels(), to_label(), set_na(), + 6 moreGet/set labels, convert formats, declare missing values
Data Transformationrec(), to_dummy(), std(), center(), find_var()Recoding, dummy coding, standardization, centering
Descriptivedescribe(), frequency(), crosstab(), multiple_response(), codebook()Summaries, distributions, multiple response sets, data dictionaries
Assumption checksnormality_test()Kolmogorov-Smirnov (Lilliefors) and Shapiro-Wilk normality tests
T-Testst_test()Mean comparisons (independent and one-sample)
ANOVAoneway_anova(), factorial_anova(), ancova()One-way, multi-factor ANOVA, and ANCOVA with Type III SS
Non-parametricmann_whitney(), kruskal_wallis(), wilcoxon_test(), friedman_test(), binomial_test()Distribution-free tests
Exact testschi_square(), fisher_test(), chisq_gof(), mcnemar_test()Categorical associations and exact tests
Correlationpearson_cor(), spearman_rho(), kendall_tau(), partial_cor()Relationships between variables, with and without controls
Post-hoctukey_test(), scheffe_test(), levene_test(), dunn_test(), pairwise_wilcoxon()Follow-up analyses (parametric and non-parametric)
Scale analysisreliability(), efa(), row_means(), row_sums(), row_count(), pomps()Cronbach's Alpha, factor analysis, index construction
Regressionlinear_regression(), logistic_regression(), marginal_effects()Linear and logistic models with SPSS-style output, average marginal effects
Effect sizesphi(), cramers_v(), goodman_gamma()Effect size measures for categorical data
Weighted statsw_mean(), w_median(), w_sd(), + 8 moreIndividual weighted statistics

Survey Weights Built-In

All statistical functions accept survey weights:

# Weighted mean, median, SD
survey_data %>%
  w_mean(age, income, weights = sampling_weight)

# Grouped weighted analysis
survey_data %>%
  group_by(region) %>%
  describe(satisfaction, weights = sampling_weight)

Tidyverse Integration

Full support for pipes and grouped operations:

survey_data %>%
  filter(age >= 18) %>%
  group_by(region) %>%
  t_test(life_satisfaction, group = gender, weights = sampling_weight)

Multi-Factor ANOVA & ANCOVA

# Factorial ANOVA with Type III SS
survey_data %>%
  factorial_anova(dv = income, between = c(gender, education),
                  weights = sampling_weight)

# ANCOVA with covariate adjustment
survey_data %>%
  ancova(dv = income, between = gender, covariate = age,
         weights = sampling_weight)

S3 Post-Hoc Methods

# Parametric: ANOVA → Tukey/Scheffe
result <- survey_data %>%
  oneway_anova(life_satisfaction, group = education, weights = sampling_weight)

result %>% tukey_test()    # Pairwise comparisons
result %>% levene_test()   # Variance homogeneity

# Non-parametric: Kruskal-Wallis → Dunn
kw_result <- survey_data %>%
  kruskal_wallis(life_satisfaction, group = education)

kw_result %>% dunn_test()  # Pairwise Dunn comparisons

Flexible Output: Compact & Detailed

Every analysis function provides two output levels. Typing the result name prints a compact one-line summary. Calling summary() produces the full SPSS-style output with all details. You can toggle individual sections on or off:

# Compact one-line summary (default)
survey_data %>%
  t_test(life_satisfaction, group = gender)

# Full detailed output
survey_data %>%
  t_test(life_satisfaction, group = gender) %>%
  summary()

# Toggle individual sections
survey_data %>%
  t_test(life_satisfaction, group = gender) %>%
  summary(effect_sizes = FALSE)

This works for all analysis functions — t_test(), oneway_anova(), chi_square(), pearson_cor(), reliability(), linear_regression(), and more.

SPSS Compatibility

Statistical functions are validated against SPSS v29 within documented per-tier tolerances, typically across four scenarios: weighted/unweighted and grouped/ungrouped. Some statistics have no SPSS equivalent (for example, the weighted variants of the rank-based tests, which SPSS's NPAR TESTS does not support) and are covered by internal regression tests instead. See vignette("spss-compatibility") for the per-function validation status. If you're migrating from SPSS, workflows translate directly:

SPSS:

WEIGHT BY sampling_weight.
T-TEST GROUPS=gender(1 2)
  /VARIABLES=satisfaction.

mariposa:

survey_data %>%
  t_test(satisfaction, group = gender, weights = sampling_weight)

Documentation

Support

License

MIT © 2026 Yannick Diehl

Copy Link

Version

Install

install.packages('mariposa')

Version

0.7.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Yannick Diehl

Last Published

September 28th, 2026

Functions in mariposa (0.7.3)

describe

Get to Know Your Numeric Data
drop_labels

Remove Unused Value Labels
find_var

Find Variables by Name or Label
frequency

Count How Many People Chose Each Option
dunn_test

Find Which Specific Groups Differ After Kruskal-Wallis
factorial_anova

Compare Groups Across Multiple Factors: Factorial ANOVA
friedman_test

Compare Three or More Related Measurements Without Assuming Normality
kendall_tau

Kendall's Tau Correlation Analysis
efa

Explore the Structure Behind Your Survey Items
fisher_test

Fisher's Exact Test for Small Samples
levene_test

Test If Groups Vary Similarly
logistic_regression

Run a Logistic Regression
mann_whitney

Compare Two Groups Without Assuming Normal Data
kruskal_wallis

Compare Multiple Groups Without Assuming Normal Data
linear_regression

Run a Linear Regression
marginal_effects

Average Marginal Effects
mcnemar_test

McNemar's Test for Paired Proportions
mariposa-package

mariposa: 'SPSS'-Compatible Statistical Tools for Survey Data
longitudinal_data_wide

Longitudinal Study Data - Wide Format (Synthetic)
longitudinal_data

Longitudinal Study Data (Synthetic)
normality_test

Test Variables for Normality
pairwise_wilcoxon

Find Which Specific Measurements Differ After Friedman Test
na_frequencies

Frequency Table of Missing Value Types
pearson_cor

Measure How Strongly Variables Are Related
partial_cor

Partial Correlation
pomps

Transform Scores to Percent of Maximum Possible (POMPS)
multiple_response

Analyze Multiple Response Sets
oneway_anova

Compare Multiple Groups: Are Their Averages Different?
print.ancova

Print ANCOVA results (compact)
print.binomial_test

Print binomial test results (compact)
predict.logistic_regression

Predict from a logistic_regression model
print.chi_square

Print chi-squared test results (compact)
print.codebook

Print a Compact Console Overview of the Codebook
print.chisq_gof

Print chi-square goodness-of-fit test results (compact)
predict.linear_regression

Predict from a linear_regression model
phi

Effect Sizes for Contingency Tables
print.dunn_test

Print Dunn post-hoc test results (compact)
print.efa

Print EFA results (compact)
print.factorial_anova

Print factorial ANOVA results (compact)
print.fisher_test

Print Fisher's exact test results (compact)
print.mann_whitney

Print Mann-Whitney test results (compact)
print.logistic_regression

Print logistic regression results (compact)
print.friedman_test

Print Friedman test results (compact)
print.oneway_anova

Print ANOVA test results (compact)
print.frequency

Print method for frequency objects (compact)
print.multiple_response

Print multiple response results (compact)
print.kruskal_wallis

Print Kruskal-Wallis test results (compact)
print.kendall_tau

Print Kendall's tau results (compact)
print.normality_test

Print normality test results (compact)
print.reliability

Print reliability results (compact)
print.scheffe_test

Print Scheffe test results (compact)
print.describe

Print method for describe objects
print.crosstab

Print method for crosstab results (compact)
print.levene_test

Print Levene test results (compact)
print.linear_regression

Print linear regression results (compact)
print.spearman_rho

Print Spearman correlation results (compact)
print.pairwise_wilcoxon

Print pairwise Wilcoxon post-hoc test results (compact)
print.summary.chisq_gof

Print summary of chi-square goodness-of-fit results (detailed output)
print.summary.codebook

Print a Detailed Console Codebook Summary
print.summary.describe

Print summary of describe results (detailed output)
print.partial_cor

Print partial correlation results (compact)
print.summary.logistic_regression

Print summary of logistic regression results (detailed output)
print.summary.crosstab

Print summary of crosstab results (detailed output)
print.summary.efa

Print summary of EFA results (detailed output)
print.mcnemar_test

Print McNemar test results (compact)
print.summary.binomial_test

Print summary of binomial test results (detailed output)
print.pearson_cor

Print Pearson correlation results (compact)
print.marginal_effects

Print average marginal effects (compact)
print.summary.dunn_test

Print summary of Dunn post-hoc test results (detailed output)
print.summary.chi_square

Print summary of chi-squared test results (detailed output)
print.summary.kruskal_wallis

Print summary of Kruskal-Wallis test results (detailed output)
print.summary.kendall_tau

Print summary of Kendall's tau correlation results (detailed output)
print.summary.factorial_anova

Print summary of factorial ANOVA results (detailed output)
print.summary.reliability

Print summary of reliability analysis results (detailed output)
print.summary.mann_whitney

Print summary of Mann-Whitney test results (detailed output)
print.summary.levene_test

Print summary of Levene test results (detailed output)
print.summary.mcnemar_test

Print summary of McNemar test results (detailed output)
print.summary.normality_test

Print summary of normality test results (detailed output)
print.summary.multiple_response

Print summary of multiple response results (detailed output)
print.summary.fisher_test

Print summary of Fisher's exact test results (detailed output)
print.summary.linear_regression

Print summary of linear regression results (detailed output)
print.summary.marginal_effects

Print summary of average marginal effects (detailed output)
print.summary.ancova

Print summary of ANCOVA results (detailed output)
print.summary.scheffe_test

Print summary of Scheffe test results (detailed output)
print.summary.oneway_anova

Print summary of one-way ANOVA results (detailed output)
print.summary.pairwise_wilcoxon

Print summary of pairwise Wilcoxon post-hoc test results (detailed output)
print.summary.frequency

Print summary of frequency results (detailed output)
print.summary.friedman_test

Print summary of Friedman test results (detailed output)
read_por

Read SPSS Portable Data with Tagged Missing Values
print.wilcoxon_test

Print Wilcoxon signed-rank test results (compact)
print.summary.tukey_test

Print summary of Tukey HSD test results (detailed output)
print.summary.wilcoxon_test

Print summary of Wilcoxon signed-rank test results (detailed output)
print.summary.partial_cor

Print summary of partial correlation results (detailed output)
print.tukey_test

Print Tukey HSD test results (compact)
print.summary.pearson_cor

Print summary of Pearson correlation results (detailed output)
print.t_test

Print t-test results (compact)
print.summary.spearman_rho

Print summary of Spearman correlation results (detailed output)
print.summary.t_test

Print summary of t-test results (detailed output)
read_sas

Read SAS Data with Tagged Missing Values
row_means

Compute Row Means Across Items
read_xlsx

Read Excel Data with Label Reconstruction
print.w_modus

Print method for w_modus objects
read_stata

Read Stata Data with Tagged Missing Values
print.w_quantile

Print method for w_quantile objects
rec

Recode Variables Using String Syntax
row_count

Count Occurrences of a Value Across Columns
row_sums

Compute Row Sums Across Items
reliability

Check How Reliably Your Scale Measures a Concept
read_spss

Read SPSS Data with Tagged Missing Values
read_xpt

Read SAS Transport File with Tagged Missing Values
strip_tags

Strip Tags from Tagged NAs
summary.chi_square

Summary method for chi-squared test results
summary.codebook

Detailed Console Summary of the Codebook
scheffe_test

Compare All Groups More Conservatively After ANOVA
set_na

Declare Values as Missing
summary.binomial_test

Summary method for binomial test results
summary.chisq_gof

Summary method for chi-square goodness-of-fit test results
summary.crosstab

Summary method for crosstab results
summary.kendall_tau

Summary method for Kendall's tau correlation results
summary.ancova

Summary method for ANCOVA results
summary.fisher_test

Summary method for Fisher's exact test results
std

Standardize Variables (Z-Scores)
summary.efa

Summarize an exploratory factor analysis
summary.factorial_anova

Summary method for factorial ANOVA results
summary.frequency

Summary method for frequency results
summary.describe

Summary method for describe results
summary.friedman_test

Summary method for Friedman test results
summary.kruskal_wallis

Summary method for Kruskal-Wallis test results
summary.dunn_test

Summary method for Dunn post-hoc test results
spearman_rho

Spearman's Rank Correlation Analysis
summary.logistic_regression

Summary method for logistic regression results
summary.mann_whitney

Summary method for Mann-Whitney test results
summary.linear_regression

Summary method for linear regression results
summary.oneway_anova

Summary method for one-way ANOVA results
summary.levene_test

Summary method for Levene test results
summary.mcnemar_test

Summary method for McNemar test results
summary.marginal_effects

Summary method for average marginal effects
summary.pairwise_wilcoxon

Summary method for pairwise Wilcoxon post-hoc test results
summary.multiple_response

Summary method for multiple response results
summary.normality_test

Summary method for normality test results
summary.partial_cor

Summary method for partial correlation results
summary.scheffe_test

Summary method for Scheffe test results
summary.wilcoxon_test

Summary method for Wilcoxon signed-rank test results
summary.t_test

Summary method for t-test results
summary.spearman_rho

Summary method for Spearman correlation results
survey_data

Social Survey Data (Synthetic)
summary.tukey_test

Summary method for Tukey HSD test results
summary.reliability

Summarize a reliability analysis
summary.pearson_cor

Summary method for Pearson correlation results
t_test

Test If Two Groups Differ
to_character

Convert Labelled Variables to Character
val_labels

Get or Set Value Labels
var_label

Get or Set Variable Labels
to_dummy

Create Dummy Variables (One-Hot Encoding)
to_labelled

Convert Variables to Labelled Format
untag_na

Convert Tagged NAs Back to Original Codes
tukey_test

Find Which Specific Groups Differ After ANOVA
to_label

Convert Labelled Variables to Factors
unlabel

Remove All Label Metadata
to_numeric

Convert Factors or Labelled Variables to Numeric
w_median

Find the Population-Representative Middle Value
w_quantile

Calculate Population-Representative Percentiles
w_mean

Calculate Population-Representative Averages
w_skew

Measure Population-Representative Skewness
w_se

Calculate Population-Representative Standard Errors
w_modus

Find the Most Common Value in Your Population
w_range

Find the Range of Your Data
w_sd

Calculate Population-Representative Standard Deviations
w_kurtosis

Measure Population-Representative Kurtosis
w_iqr

Measure Population-Representative Spread (IQR)
write_spss

Export Data to SPSS Format
write_stata

Export Data to Stata Format
w_var

Calculate Population-Representative Variance
write_xpt

Export Data to SAS Transport Format
wilcoxon_test

Compare Two Related Measurements Without Assuming Normality
write_xlsx

Export Data to Excel with Label Support
chisq_gof

Chi-Square Goodness-of-Fit Test
chi_square

Test If Two Categories Are Related
anova.linear_regression

ANOVA for a linear_regression model
crosstab

Compare Two Categories: See How They Relate
copy_labels

Copy Labels from One Data Frame to Another
anova.logistic_regression

ANOVA for a logistic_regression model
codebook

Create a Codebook for Your Data
ancova

Analysis of Covariance: ANCOVA
center

Center Variables (Mean Centering)
binomial_test

Test Whether a Proportion Matches an Expected Value