View source: R/grouped_center.R
grouped_center | R Documentation |
Centers a numeric variable within optional groups and optional weights. The order of values is unchanged.
grouped_center(data, x, w = NULL, by = NULL, ...)
data |
A |
x |
Variable name in |
w |
Optional name of the column in |
by |
An optional vector of column names in |
... |
Additional arguments passed to mean calculation (e.g. |
A numeric vector with centered values in column x
.
ir <- data.frame(iris, w = 1)
mean(grouped_center(ir, "Sepal.Width"))
rowsum(grouped_center(ir, "Sepal.Width", by = "Species"), ir$Species)
mean(grouped_center(ir, "Sepal.Width", w = "w"))
rowsum(grouped_center(ir, "Sepal.Width", by = "Species", w = "w"), ir$Species)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.