Hi.
I have a large dataset with two columns - ID and Status. I want to create a table to know how many observations are unique, 1 duplicate, 2 duplicates, 3 duplicates and so on...How will the code look like?
Thanks.
yoyong
Hi.
I have a large dataset with two columns - ID and Status. I want to create a table to know how many observations are unique, 1 duplicate, 2 duplicates, 3 duplicates and so on...How will the code look like?
Thanks.
yoyong
I think you want to use the table() function. Here is an example. The numbers in the table show how many times each combination occurs.
DF <- data.frame(ID = c("A", "C", "B", "A", "B", "C", "C", "B"),
Status = c(2,3,1,3,2,1,3,2))
DF
ID Status
1 A 2
2 C 3
3 B 1
4 A 3
5 B 2
6 C 1
7 C 3
8 B 2
table(DF$ID, DF$Status)
1 2 3
A 0 1 1
B 1 2 0
C 1 0 2
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.