psych350lab provides helper functions for a Research Methods and Statistical Analysis lab course. It streamlines running common statistical analyses, generating APA-formatted tables, and creating interactive student worksheets — all from R and Quarto/RMarkdown.
Installation
You can install psych350lab using the pak package, which handles both CRAN and GitHub installations seamlessly.
Install from GitHub (recommended)
To install you need to first set up GitHub authentication first.
# Install required packages if neededinstall.packages(c("gitcreds", "usethis"))# Check if credentials are already configuredgitcreds::gitcreds_get()# If not configured, create a Personal Access Token:usethis::create_github_token() # This opens GitHub with the correct scopes pre-selected.# Generate the token, copy it, then run:gitcreds::gitcreds_set()# Paste your token when prompted
Step 2: Install the package
pak::pak("emmarshall/psych350lab")
Install from a local source
If you have a local copy of the package (e.g., a .tar.gz file or a cloned repo), you can install it with:
# From a .tar.gz filepak::pak("local::path/to/psych350lab_0.1.0.tar.gz")# From a local directorypak::pak("local::path/to/psych350lab")
Troubleshooting authentication
If you encounter authentication errors:
# Check your current GitHub configurationusethis::git_sitrep()# Reset and reconfigure credentialsgitcreds::gitcreds_set()
Overview
The package is organized around several core analysis workflows, each with a computation function (*_answers()) and companion table/formatting functions.
Data Import
Function
Description
get_spss_data()
Read SPSS .sav files, convert missing values, and strip labels
Correlation Analysis
Function
Description
corr_answers()
Compute Pearson correlation with descriptives and hypothesis test
create_corr_table()
Compact flextable with r, p, df, means, SDs
format_corr_results()
Fill-in-the-blank or answer key text output
create_apa_corr_table()
APA correlation matrix with significance stars
create_corr_matrix_checker()
Interactive webexercise correlation matrix
Between-Groups ANOVA
Function
Description
bg_anova_answers()
One-way between-groups ANOVA with group descriptives
format_bg_anova_results()
Fill-in-the-blank or answer key text
create_bg_anova_table()
APA descriptive statistics table
create_anova_source_table()
APA ANOVA source table (SS, df, MS, F, p)
create_bg_anova_combined_table()
Combined ANOVA + descriptives flextable
Within-Groups (Repeated Measures) ANOVA
Function
Description
wg_anova_answers()
Repeated measures ANOVA for two conditions
format_wg_anova_results()
Fill-in-the-blank or answer key text
create_wg_anova_table()
APA descriptive statistics table
create_wg_anova_combined_table()
Combined ANOVA + descriptives flextable
Chi-Square Analysis
Function
Description
chi_square_answers()
Compute chi-square goodness-of-fit or 2×k test with effect size
chi_square_kgroup_answers()
K-group chi-square with pairwise comparisons and Bonferroni correction
pr_chi_to_r()
Convert 2×2 contingency cell counts to chi-square, p, and r
format_chi2_results()
Fill-in-the-blank or answer key text output
create_rh_contingency()
Display contingency table with observed/expected counts
create_chi_crosstabs_table()
Crosstabs table with counts and percentages
create_chi_combined_table()
Combined chi-square results and crosstabs table
format_chi_omnibus_results()
Formatted omnibus results with highlighting
chisq_pairwise_KEY()
Pairwise comparison results table
K-Group ANOVA
Function
Description
anova_kgroup_answers()
K-group one-way ANOVA with group descriptives and pairwise comparisons
pr_means_to_r()
Convert group means and n to between-groups effect size
lsd_hsd_calculator()
Compute LSD and HSD minimum mean differences
create_rh_support_text()
Formatted hypothesis support text
anova_statistics_KEY()
ANOVA statistics answer key display
anova_descriptives_KEY()
Group descriptive statistics answer key display
Factorial (Two-Way) ANOVA
Function
Description
anova_factorial_answers()
2×2 factorial ANOVA via jmv with EMMs and post-hoc
lsd_hsd_calculator()
Compute LSD and HSD minimum mean differences
check_factor_alignment()
Diagnostic check for factor level ordering
Multiple Regression
Function
Description
regression_answers()
Full regression with univariate, bivariate, and multivariate results plus interpretation categories (a–d)
regression_model_statistics()
Formatted model summary line (R, R², F, df, p)
regression_model_evaluation()
“Does the model work?” / “How well?” text
create_regression_combined_table()
Flextable with r, b, type, and result category per predictor
regression_table_legend()
Markdown legend for result categories
regression_category_legend()
Extended markdown legend
create_correlation_interp_ft()
Flextable with auto-generated correlation interpretations
create_regression_weight_interp_ft()
Flextable with regression weight interpretations
Interactive Webexercise Checkers (for Quarto)
Function
Description
create_model_summary_checker()
Fill-in-the-blank model summary (tinytable + webexercises)
Most table and formatting functions include a Key (or KEY) argument. Set Key = TRUE for a filled answer key, or Key = FALSE for a blank student worksheet — making it easy to generate both versions from the same code.
Several functions generate interactive fill-in-the-blank and multiple-choice tables powered by webexercises and tinytable. These are designed for use in Quarto HTML documents:
# In a Quarto documentcreate_model_summary_checker(result)create_predictor_checker(result)
Sample Data
The package includes superman_data, a dataset used throughout the examples and course materials.