Pearson Correlation Analysis

Description

Computes a Pearson correlation between two variables, including descriptive statistics computed separately for each variable (matching SPSS/Jamovi behavior) and inferential statistics for complete pairs.

Usage

corr_answers(data, var1, var2)

Arguments

data A data frame or tibble.
var1 Character string. Name of the first variable.
var2 Character string. Name of the second variable.

Value

A list with three elements:

Correlation
A list containing r, p_value, df, CI_low, CI_high, and method. All numeric values are unrounded.
Descriptives
A tibble with variable, mean, sd, n, and sem for each variable (using all available cases per variable). Unrounded.
Sample_Size
The number of complete pairs used in the correlation.

Examples

library("psych350lab")

data(superman, package = "psych350data")
result <- corr_answers(superman, "clark_height_in", "rt_critics_score")
result$Correlation$r
[1] 0.02680351
result$Descriptives
# A tibble: 2 × 5
  variable          mean    sd     n   sem
  <chr>            <dbl> <dbl> <int> <dbl>
1 clark_height_in   73.4  1.68    11 0.507
2 rt_critics_score  79.4 10.5      8 3.72