Simple function to calculate effect sizes for mean differences.
smd(x, g, index = c("all", "1", "2"))
The standardized mean difference.
A continuous variable
A grouping variable, with two levels
A character string: “all” uses pooled variance, “1” uses the first factor level variance, “2” uses the second factor level variance.
smd(mtcars$mpg, mtcars$am)
smd(mtcars$mpg, mtcars$am, "all")
smd(mtcars$mpg, mtcars$am, "1")
smd(mtcars$mpg, mtcars$am, "2")
smd(mtcars$hp, mtcars$vs)
d <- data.table::as.data.table(mtcars)
d[, smd(mpg, vs)]
rm(d)
Run the code above in your browser using DataLab