Created
June 11, 2017 10:28
-
-
Save czeildi/59d475a8ab2764faa2d4302dc06f433a to your computer and use it in GitHub Desktop.
compute cumulative unique N with R's data.table package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dt <- data.table(x = c(4,4,2,5,4,2,3)) | |
dt[, g := .GRP, by = x] | |
dt[, cumuniquen := cummax(g)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment