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