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)

Arguments

svy_data

A survey object created with the survey or srvyr package. Only numeric variables will be included in the result.

var_names

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()

return_n

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.

Value

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.

Examples

if (FALSE) {
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)
}
}