View source: R/survey_statistics.r
survey_corr | R Documentation |
Calculate correlation from complex survey data. A wrapper
around svyvar
. survey_corr
should always be
called from summarise
. Note this is Pearson's correlation.
survey_corr( x, y, na.rm = FALSE, vartype = c("se", "ci", "var", "cv"), level = 0.95, df = NULL, ... )
x |
A variable or expression |
y |
A variable or expression |
na.rm |
A logical value to indicate whether missing values should be dropped |
vartype |
NULL to report no variability. Otherwise one or more of: standard error ("se", the default), confidence interval ("ci"), variance ("var") or coefficient of variation ("cv"). |
level |
(For vartype = "ci" only) A single number or vector of numbers indicating the confidence level |
df |
(For vartype = "ci" only) A numeric value indicating the degrees of freedom for t-distribution. The default (NULL) uses degf, but Inf is the usual survey package's default |
... |
Ignored |
data('api', package = 'survey') apisrs %>% as_survey_design(.ids = 1) %>% summarize(api_corr = survey_corr(x = api00, y = api99)) apisrs %>% as_survey_design(.ids = 1) %>% group_by(sch.wide) %>% summarize( api_emer_corr = survey_corr(x = api00, y = emer, na.rm=TRUE, vartype="ci") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.