View source: R/group_mean_center.R
group_mean_center | R Documentation |
Returns data including group means and group mean centered variables
group_mean_center(data, group.var, vars, grand.init = FALSE)
data |
Data frame of individual observations across multiple groups. |
group.var |
Character string name of the grouping variable. |
vars |
Vector of numeric variable names to be centered. |
grand.init |
Is initial grand mean centering to each variable applied (default FALSE)? |
Data frame with group means and variables centered around group means.
set.seed(234) n1 <- 3 # groups n2 <- 3 # observations per groups dat <- data.frame( group = rep(c(LETTERS[1:n1]), each = n2), x1 = sample(1:5, n1 * n2, replace = TRUE), x2 = sample(1:5, n1 * n2, replace = TRUE), x3 = sample(1:5, n1 * n2, replace = TRUE) ) group_mean_center( data = dat, group.var = "group", vars = c("x1", "x2", "x3") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.