# FALLBACK
library(dplyr)
if(!exists("raw_data")) {
raw_data <- data.frame(
age = rnorm(50, 20, 2),
anxiety = rnorm(50, 10, 3),
depression = rnorm(50, 10, 3)
)
}
# 1. Select Numeric Vars
numeric_vars <- raw_data %>%
select(where(is.numeric))
# 2. Compute Correlation
cor_mat <- cor(numeric_vars, use = "complete.obs")
# 3. Simple Visualization (Round to 2 decimals)
round(cor_mat, 2) %>%
knitr::kable(caption = "Pearson Correlations")| age | anxiety | depression | |
|---|---|---|---|
| age | 1.00 | -0.12 | -0.14 |
| anxiety | -0.12 | 1.00 | -0.25 |
| depression | -0.14 | -0.25 | 1.00 |