Re: [R] matching observations and ranking

2013-04-24 Thread arun
Just to add: If your original dataset have only few columns, then you can try this too: res1<-within(mutate(dat1,AB001A_1=1*(AB001A==AB001A[2]),AB0002A_1=1*(AB0002A==AB0002A[2]),AB362_1=1*(AB362==AB362[2]),SUM=rowSums(cbind(AB001A_1,AB0002A_1,AB362_1)),MATCH=(SUM/3)*100),{MATCH[1:2]<-NA;RANK=rank(M

Re: [R] matching observations and ranking

2013-04-24 Thread arun
Hi, May be this helps: As you wanted to match only from row3 onwards to row2, the corresponding values on row1 and row2 were set to NA. dat1<- read.table(text="   S.No AB001A AB0002A AB362    P1   -/-    C/C   A/A       P2   C/C    C/C   A/A      

Re: [R] matching observations and ranking

2013-04-23 Thread arun
Hi, It is not that clear. If VAR1 is a match between columns AB001A, AB0002A, VAR2  between AB001A, AB362 and VAR3 between AB0002A and AB362: Also, I assume row8 match would be taken as 1. dat1<- read.table(text="   S.No AB001A AB0002A AB362    1   -/-    C/C   A/A