R/cor_tables.R
svy_cor_matrix.Rd
This function wraps jtools::svycor() so that it works in a srvyr-pipeline, runs bootstrapped significance-tests and calculates weighted summary statistics. Only numeric variables are included in the result.
svy_cor_matrix(svy_data, var_names = NULL, return_n = FALSE)
A survey object created with the survey or srvyr package. Only numeric variables will be included in the result.
A named character vector with new variable names or a tibble as provided by get_rename_tribbles()
for variables. If NULL, then the variables are not renamed. If names are provided, only the variables included here are retained.
This is most helpful when the results are passed to some print function, such as report_cor_table()
Should the sample size be returned? Note that this is not survey-weighted, and should thus only be used when the weights add up to the number of observations.
A correlation matrix list in the format provided by
jtools::svycor()
with the addition of a desc
-element with means
and standard deviations of the variables.
if (FALSE) { # \dontrun{
if (requireNamespace("survey") & requireNamespace("srvyr")) {
library(survey)
library(srvyr)
data(api)
# Create survey design object
dstrat <- apistrat %>% as_survey_design(1, strata = stype, fpc = fpc, weight = pw)
var_names <- c(meals = "Share subsidized meals", ell = "English language learners",
growth = "Performance Change")
# Print correlation matrix
svy_cor_matrix(dstrat, var_names)
}
} # }