Quantcast

Extract elements of an unequal list to a matrix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Extract elements of an unequal list to a matrix

Evgenia
This post has NOT been accepted by the mailing list yet.
I have a list as x
x <- list()
x[[1]] <- data.frame(matrix(c(0,40,82,1,5,10,2,4,8),ncol=3, byrow=T))
                     
names(x[[1]]) <- c("x","freq","%")
x[[2]] <- data.frame(matrix(c(8,49,100),ncol=3, byrow=T))
names(x[[2]]) <- c("x","freq","%")
x[[3]] <- data.frame(matrix(c(0,35,71,1,3,6,2,8,16,9,3,6),ncol=3, byrow=T))
names(x[[3]]) <- c("x","freq","%")

I want to extract elements as below

m<-matrix(c(40,82,5,10,4,8,rep(NA,4),rep(NA,6), 49,100,rep(NA,2),35,71,3,6,8,16,rep(NA,2),3,6),ncol=10)
colnames(m)<-c("freq0","%0","freq1","%1","freq2","%2","freq8","%8","freq9","%9")


Thanks
Evgenia




Loading...