Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- aggregate(paste(ID , Date) ~ ID + Date, data = df, FUN = length)
- library(dplyr)
- df %>% group_by(ID, Date) %>% summarise(PurchaseCount = n())
- df %>% group_by(ID, Date) %>% tally(name="PurchaseCount")
- df %>% group_by(ID, Date) %>% count(name="PurchaseCount")
- df %>% group_by(ID, Date) %>% add_tally(name="PurchaseCount")
- df %>% group_by(ID, Date) %>% add_count(name="PurchaseCount")
- library(data.table)
- setDT(df)[, PurchaseCount:=.N, by = list(ID, Date)]
- library(sqldf)
- sqldf("SELECT ID, Date, COUNT(*) as PurchaseCount
- FROM df
- GROUP BY Date, ID")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement