search for: comparetworow

Displaying 1 result from an estimated 1 matches for "comparetworow".

Did you mean: comparetworows
2010 Jul 13
2
Checking for duplicate rows in data frame efficiently
...1,1,1,1,1, 2,2,2,2,2, 7,7,7,7,7), ncol=5, byrow=TRUE) > df <- data.frame(m) > df X1 X2 X3 X4 X5 1 1 1 1 1 1 2 2 2 2 2 2 3 6 6 6 6 6 4 3 3 3 3 3 5 4 4 4 4 4 6 5 5 5 5 5 7 1 1 1 1 1 8 1 1 1 1 1 9 2 2 2 2 2 10 7 7 7 7 7 > > compareTwoRows <- function(row1, row2){ + numCol <- 5 + logicalRow <- row1==row2 + duplicate <- sum(logicalRow)==numCol + return(as.numeric(duplicate))} > > same <- matrix(0, byrow=TRUE, ncol=10,nrow=10) > > for (j in 1:9) + for (k in (j+1):10) + same[j,k] <- compareTwoRo...