svy_cor_matrix | R Documentation |
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)
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 |
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. |
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.
## Not run:
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)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.