My data is a set from big data. Each unique ID includes one or more class, and each class includes one or more unique values of X. BUT, we may have same class in different IDs (i.e, ID009 and ID020 have same class) I'm trying to find out how many unique values of X per class value based on different ID.
ID <- c("ID004", "ID004", "ID004", "ID004", "ID004", "ID004", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID006", "ID009", "ID009", "ID009", "ID009", "ID009", "ID009", "ID009","ID020", "ID020", "ID020", "ID020", "ID020", "ID020", "ID020", "ID020", "ID023", "ID023", "ID023", "ID023", "ID023", "ID023","ID023", "ID023", "ID023", "ID023")
Class <- c("CMP-001", "CMP-001", "CMP-001", "CMP-001", "CMP-001","CMP-001", "CMP-001", "CMP-001", "CMP-001", "CMP-001", "CMP-001","CMP-001", "CMP-001", "CMP-001", "CMP-002", "CMP-002", "CMP-002","CMP-002", "CMP-002", "CMP-005", "CMP-005", "CMP-005", "CMP-002", "CMP-002", "CMP-002", "CMP-002", "CMP-002","CMP-002", "CMP-002", "CMP-002", "CMP-002", "CMP-002", "CMP-002", "CMP-002","CMP-002", "CMP-004", "CMP-004", "CMP-001", "CMP-001", "CMP-001", "CMP-001", "CMP-001","CMP-001", "CMP-001", "CMP-001", "CMP-001", "CMP-001")
X <- c(1,1,2,3,3,3,4,4,4,4,4,4,4,4,5,5,6,6,6,7,7,8,9,9,10,10,10,10,10,11,11,12,12,13,13,14,14,15,15,15,16,16,17,17,18,18,18)
data <- data.frame(ID, Class, X)
the result should be;
ID class No. of X value
ID004 CMP-001 3
ID006 CMP-001 1
CMP-002 2
CMP-005 2
ID009 CMP-002 2
ID020 CMP-002 3
CMP-004 1
ID023 CMP-001 4
Thank you for your help,