svy_cohen_d_pair | R Documentation |
This function calculates a t.test() for two groups in a srvyr
survey
object. It is particularly helpful when the grouping variable has more than
two levels and you just want to compare two of them.
svy_cohen_d_pair(data, dv, iv, pair = NULL, ttest = TRUE, print = FALSE)
data |
A survey object |
dv |
Character. Name of the dependent variable for the t.test (numeric) |
iv |
Character. Name of the grouping variable for the t.test (factor) |
pair |
Character vector of length 2. Levels of iv to be compared in t.test. Can be NULL if iv only has two distinct values. |
ttest |
Logical. Should t.test be run? Otherwise, only Cohen's d is calculated. Defaults to TRUE. |
print |
Logical. Should results be printed. |
Returns a one-row tibble with tidy results of t-test and Cohen's d. If print is TRUE, results are returned invisibly.
library(srvyr)
#Create weights (consists of two variables in ESS)
ess_health$svy_weight <- ess_health$pspwght * ess_health$pweight
ess_survey <- as_survey(ess_health,
weights = svy_weight)
svy_cohen_d_pair(ess_survey, "health", "cntry", pair = c("DE", "GB"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.