I have the following data frame:
ID T1 T2
a no no
a no yes
a no yes
b no no
b yes no
If there is a yes for the column for the same ID then I want to write "yes" in another column, if there is never a "yes" for the same ID then I just want a "no" in the new data frame. So I want to create the following data frame:
ID T1 T2
a no yes
b yes no
So far I have this:
for ( i in 1:end){
sameCol=TRUE
for (j in 1:end2){
subID = table[j,1]
if (table[j,i]=="yes"){
if (table[j,1]==table[j-1,1]){
isSAME=TRUE
}
isyes=TRUE
}
if((isyes==TRUE) & (isSAME==TRUE){
table2[j,i]="yes"
} else {
table2[j,i]="no"
}
}
}
But my code unfortunately doesn't work, what am I doing wrong?