Displaying 1 result from an estimated 1 matches for "savecol2".
2007 Jul 22
2
Write columns from within a list to a matrix?
...]]=cbind(runif(15), rnorm(15,2)) } #create example list (I'm sure there is a better way to do this too).
#Now, I wan to get the second column back out, converting it from a list to a matrix. This works, but gets confusing/inefficient when I have multiple complex lists I am trying to manage.
savecol2=matrix(0,15,0)
for (i in 1:3){
savecol2=cbind(savecol2, test[[i]][,1])
}
#Something like??: (of course this doesn't work)
savecol2=sapply(test, "[[", function(x) x[2,])
Thank you!
Jeff