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

[R] frequency table for a list matching some conditions

2010-08-26 Thread Olga Lyashevska
Dear all, I have a list that contains 3 sublists( x1, x2, x3) 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")) mylist $x1 [1] "A" "A" "A" "B" "C" "Z" "Y" $x2 [1] "D" "D" "E" "E" "F" "Z" "X" $x3 [1] "A" "A" "A" "B" "Y" "Z" I also ha