Let's consider the following data
data <- data.frame(V1 = c("A","A","A","B","B","C","C"), V2 = c("B","B","B","C","C","D","D"))
> data
V1 V2
1 A B
2 A B
3 A B
4 B C
5 B C
6 C D
7 C D
Now we aggregate data by both columns and obtain
library(dplyr)
group_by(data, V1, V2) %>% summarise(n())
V1 V2 n()
(fctr) (fctr) (int)
1 A B 3
2 B C 2
3 C D 2
Now we want to turn this data back into original data. Is there any function for this procedure?