I am trying to find a faster alternative to comparing each observation i with observation j within data frame X. For example, running the following code
for(i in 1:nrow(X)){
for(j in 1:nrow(X)){
if ( (sum(c(X$Feature1[i], X$Feature1[j])) == 0)&& ((X$Feature2[i] == X$Feature2[j])|(X$Feature3[i] == X$Feature3[j]) ) ){
X$match[i]<-1
}}}
it takes quite a while to run with 20,000 or so observations. Is there any sorting/comparison algorithm in R that anyone is aware of? Thanks in advance for your time!