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 have another list, that contains some specific elements.
newlist<-c("A","B","C","D","E","F")
newlist
[1] "A" "B" "C" "D" "E" "F"

I want to match mylist[1], mylist[2], etc with newlist and I am looking for the 
following output:

        A  B  C  D  E  F
x1      3  1  1  NA NA NA
x2      NA NA NA 2  2  1
x3      3  1  NA NA NA NA

Any thoughts?

Many thanks 
Olga

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to