
Summary Table of Composite Index Component Variables
Source:R/composite_index.R
index_variable_table.RdGenerates a tidy summary table of component variables comprising a composite index, reporting weights/loadings, correlation with the index, mean, SD, and p-value.
Usage
index_variable_table(
data,
cols,
index_col = "composite_index",
method = c("pearson", "spearman")
)Examples
df <- data.frame(sbp = c(120, 140, 160), dbp = c(80, 90, 100), bmi = c(22, 28, 35))
df <- compute_composite_index(df, cols = c("sbp", "dbp", "bmi"))
index_variable_table(df, cols = c("sbp", "dbp", "bmi"), index_col = "composite_index")
#> # A tibble: 3 × 5
#> variable mean sd r_with_index p_value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 sbp 140 20 1.000 0.00942
#> 2 dbp 90 10 1.000 0.00942
#> 3 bmi 28.3 6.51 1.000 0.0188