Re: [R] frequency table for a list matching some conditions

2010-08-26 Thread Olga Lyashevska
Thanks Dimitris, It works nicely! Regards, Olga On Thu, 2010-08-26 at 11:55 +0200, Dimitris Rizopoulos wrote: > one way is the following: > > mylist <- list(x1 = c("A","A","A","B","C","Z","Y"), > x2 = c("D","D","E","E","F","Z","X"), > x3 = c("A","A","A","B","Y","Z")) > newlist <- c("

Re: [R] frequency table for a list matching some conditions

2010-08-26 Thread Dimitris Rizopoulos
one way is the following: mylist <- list(x1 = c("A","A","A","B","C","Z","Y"), x2 = c("D","D","E","E","F","Z","X"), x3 = c("A","A","A","B","Y","Z")) newlist <- c("A","B","C","D","E","F") tab <- t(sapply(mylist, function (x) table(factor(x, levels = newlist tab[tab == 0] <- NA tab