count unique combinations of variable values in an R dataframe column [duplicate]
问题 This question already has answers here : Collapse / concatenate / aggregate a column to a single comma separated string within each group (4 answers) Count number of rows within each group (15 answers) Closed 5 months ago . I want to count the unique combinations of a variable that appear per group. For example: df <- data.frame(id = c(1,1,1,2,2,2,3,3,4,4,4,5,6,6,7,7,7), status = c("a","b","c","a","b","c","b","c","b","c","d","b","b","c","b","c", "d")) > df id status 1 1 a 2 1 b 3 1 c 4 2 a 5