| center_within_cluster | R Documentation |
Subtracts each cluster mean from a numeric vector. Missing cluster values produce missing centered values. This helper is used by the regression wrappers in their generated 'setup' code and can also be used in hand-written 'rtmb_code()' models.
center_within_cluster(x, cluster, na.rm = TRUE)
x |
Numeric vector to center. |
cluster |
Vector identifying the cluster for each element of 'x'. |
na.rm |
Logical; whether missing values are removed when calculating cluster means. |
A numeric vector with the same length as 'x'.
center_within_cluster(c(1, 3, 2, 6), c("a", "a", "b", "b"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.