Displaying 1 result from an estimated 1 matches for "falserow".
Did you mean:
falseop
2006 Sep 28
1
Comparing entire row sets at once efficiently
...Comparison.
A toy example:
> Comparison <- matrix(1:30, ncol=5)
> Candidates <- Comparison[c(2,4), ]
> checkRow <- function(r, M) { any( (r[1] == M[,1]) & (r[2] == M[,2]) & (r[3] == M[,3]) & (r[4] == M[,4]) ) }
> checkRow( Candidates[1,], Comparison)
[1] TRUE
> falseRow <- Candidates[1,]
> falseRow[2] <- 42
> checkRow( falseRow, Comparison)
[1] FALSE
>
The checkRow function works but is a) klunky, b) hardcodes the dimension and
c) works only on one row at a time.
There must be better ways, at least for a) and b). What am I missing?
Feel free...