Re: [R] matching values in a list

2008-01-11 Thread dxc13
That's a very creative way to get the results! I haven't used the "table" call before, but that certainly made it much easier. Thanks! Gabor Grothendieck wrote: > > The first line was missing. It should be: > > mat <- do.call(rbind, a) > sapply(apply(mat, 2, table), function(x) mean(as.numer

Re: [R] matching values in a list

2008-01-11 Thread Gabor Grothendieck
The first line was missing. It should be: mat <- do.call(rbind, a) sapply(apply(mat, 2, table), function(x) mean(as.numeric(names(x))[x == length(a)])) On Jan 11, 2008 7:23 PM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Assume that no component matrix can have repeated values. > > First we

Re: [R] matching values in a list

2008-01-11 Thread Gabor Grothendieck
Assume that no component matrix can have repeated values. First we apply table to mat yielding a list of named counts. To each component of that we sapply the indicated function which picks out those that occur length(a) times (so they are in every column), converts the name to numeric and average

[R] matching values in a list

2008-01-11 Thread dxc13
useR's, I want to match the real number elements of a list that has 3 matrices as its elements and then average those numbers. I think I am close, but I can't get it to quite work out. For example, > a <- list(matrix(c(10,NA,NA,12,11, > 10,13,NA,14,12),ncol=2),matrix(c(10,12,15,13,11, > 13,NA,