I have a dataset that looks like this:
SID group timepoint
5402 A 0
5402 B 0
5402 C 1
5403 A 0
25403 B 1
25403 C 1
I want to count how many unique SID's are there per group x timepoint. So far I have been doing the combinations 'by hand', like this:
length(unique(subset(df, timepoint=='0' & group=='A')$SID))
length(unique(subset(df, timepoint=='0' & group=='B')$SID))
...
Is there a way to use a grouping function that gives me a table with all the counts? (like by
, or tapply
?)
Thanks!