Entering edit mode
2.9 years ago
martin.gallix
▴
20
Hi everybody, I would like to count the occurrences in a dataframe, for example if my dataframe is:
0 0 0
0 1 0
0 0 0
1 1 1
0 1 0
I would like to have the count of each unique combinations.
000 : 3
010 : 2
111 : 1
Anybody have ideas on how I can do it on R ? Thank you.
table(df$col1,df$col2) does exactly the same as df %>% count(col1, col2). No reason to use bloated tidyverse when base R can do it :)
EDIT: actually there's a difference: count will not include cases with 0 occurrences. It may or may not be desirable.