Casting multiple value.var controled by fun.aggregate
问题 I have the following dataset client_id <- c("A", "A", "B", "B", "B", "B", "B", "A", "A", "B", "B") value <- c(10, 35, 20, 30, 50, 40, 30, 40, 30, 40, 10) period_30 <- c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0) period_60 <- c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0) sign <- c("D", "D", "D", "D", "C", "C", "C", "D", "D", "D", "D") data <- data.frame(client_id, value, period_30, period_60, sign) I can use this code to count the number of different splits per given period with the code below: library(data.table)