c_mean | R Documentation |
c_mean() computes the cluster mean for given variable, and a given clustering variable
c_mean(x, j)
x |
a numeric vector of a single variable |
j |
a numeric vector that indexes values into groups |
simple wrapper for 'ave(variable, group)' function, to estimate cluster means
a numeric vector
example_data <- data.frame(x = c(1,2,3,4,5,6), j = c(1,1,1,2,2,2))
library(dplyr)
example_data %>%
mutate(cluster_mean = c_mean(x, j)) %>%
select(cluster_mean, j) %>%
unique() %>%
print
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.