[R] Transforming list to data frame with corresponding columns

From: LCOG1 <jroll_at_lcog.org>
Date: Mon, 07 Jun 2010 12:20:47 -0700 (PDT)

Hi all,

   Consider the following.

a<-list(c("MHsub","MHsub","SFD","Duplex"))
b<-list(c("MHsub","MHsub","SFD"))
c<-list(c("MHpark","SFD","SFD"))
d<-list(c("MultiFam","MultiFam","MultiFam","Duplex"))

all<-list(a,b,c,d)
names(all)<-c("5","6","7","8")
all2<-list()
for(i in 1:length(all)){
all2[[i]]<-table(unlist(all[i]))
}
names(all2)<-names(all)

What i want to do is to put each of the elements of the list into a data frame where the element represents a row and each vector is accounted for, for all types within the entire list. So where there isnt a particular vector a 0 is noted so that the final product looks like this:

	SFD	Mhsub	Duplex	MultiFam
5	1	   1	            1               0
6	1	   1	            0	            0
7	1	   1	            0	            0
8	0	   0	            1	            1 

Thanks for the insights.  

-- 
View this message in context: http://r.789695.n4.nabble.com/Transforming-list-to-data-frame-with-corresponding-columns-tp2246423p2246423.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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.
Received on Mon 07 Jun 2010 - 21:02:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jun 2010 - 21:40:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive