An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111011/08875d84/attachment.pl>
binding all elements of list (character vectors) to a matrix as rows
4 messages · Gerrit Eichner, David Winsemius, Marion Wenty
Marion, try rbind( Mymatrix, do.call( "rbind", Z)) Hth -- Gerrit
On Tue, 11 Oct 2011, Marion Wenty wrote:
dear r-users,
i have got a problem which i am trying to solve:
i have got the following commands:
Mymatrix <- matrix(1:9,ncol=3)
Z <-
list("V1"=c("a","",""),"V2"=c("b","",""),"V3"=c("c","",""),"V4"=c("d","",""))
Mymatrix <- rbind(Mymatrix,Z[[1]],Z[[2]],Z[[3]],Z[[4]])
now this is working, but i would like to substitute
Z[[1]],Z[[2]],Z[[3]],Z[[4]]
for a command with which i could also use another list with a different
number of elements, e.g. 5 or 6 elements.
does anyone know the solution to this problem?
thank you very much in advance!
marion
[[alternative HTML version deleted]]
______________________________________________ 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.
On Oct 11, 2011, at 2:47 AM, Marion Wenty wrote:
dear r-users,
i have got a problem which i am trying to solve:
i have got the following commands:
Mymatrix <- matrix(1:9,ncol=3)
Z <-
list
("V1
"=c("a","",""),"V2"=c("b","",""),"V3"=c("c","",""),"V4"=c("d","",""))
rbind(Mymatrix, t(as.data.frame(Z))) The next method could be used if you had more lists: do.call(rbind, list(Mymatrix, t(as.data.frame(Z))))
Mymatrix <- rbind(Mymatrix,Z[[1]],Z[[2]],Z[[3]],Z[[4]]) now this is working, but i would like to substitute Z[[1]],Z[[2]],Z[[3]],Z[[4]] for a command with which i could also use another list with a different number of elements, e.g. 5 or 6 elements.
David Winsemius
2 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111014/1cbc8389/attachment.pl>