c_sum: c_sum() computes the cluster sum for a given variable, and a...

View source: R/c_sum.R

c_sumR Documentation

c_sum() computes the cluster sum for a given variable, and a given clustering variable

Description

c_sum() computes the cluster sum for a given variable, and a given clustering variable

Usage

c_sum(x, j)

Arguments

x

a numeric vector of a single variable

Details

simple wrapper for 'ave(variable, group)' function, to estimate cluster sum

Value

a numeric vector

Examples

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

dacarras/r4sda documentation built on Nov. 9, 2023, 10:17 a.m.