Not sure what you intend with regard to length but to get a logical
vector indicating which rows equal a particular vector:
f1 <- function(tb, row) apply(tb,1,function(x)all(x==row))
# or without using apply:
f2 <- function(tb, row) colSums( abs( (t(tb) - row) ) ) == 0
# or in terms of a gener
Hi!
?apply
...: optional arguments to 'FUN'.
you can pass more arguments to your function.
length(apply(tb,comare,c(0,3,1)))
Sincerely
Eryk.
*** REPLY SEPARATOR ***
On 5/28/2004 at 12:05 PM anoly wrote:
>Dear all:
>I meet a problem of apply function. I have a matrix called t
Dear all:
I meet a problem of apply function. I have a matrix called tb
>tb
V1 V2 V3
1 0 3 1
2 1 4 0
3 0 3 0
4 0 4 0
5 0 3 1
6 1 4 1
7 1 1 0
8 1 3 0
9 0 1 1
10 0 3 1
I hope to get the number of row that match c(0,3,1)
I do this way:
>length(apply(t(tb) = =