Let\'s say I have the following data frame:
> myvec
name order_no
1 Amy 12
2 Jack 14
3 Jack 16
4 Dave 11
5 Amy
Few years old .. although had similar requirement and ended up writing my own solution. Applying here:
x<-data.frame(
"Name"=c("Amy","Jack","Jack","Dave","Amy","Jack","Tom","Larry","Tom","Dave","Jack","Tom","Amy","Jack"),
"OrderNo"=c(12,14,16,11,12,16,19,22,19,11,17,20,23,16)
)
table(sub("~.*","",unique(paste(x$Name,x$OrderNo,sep="~",collapse=NULL))))
Amy Dave Jack Larry Tom
2 1 3 1 2