Suppose, I have following
vec <- vector("list", length=3)
for (i in 1:3) vec[[i]] <- matrix(rnorm((i+3)*2), (i+3))
vec
Now I want to change the type of "vec" from list to a matrix with
(4+5+6)
rows and 2 columns. How can I do that?
Thanks and regards,
--
View this message in context:
http://www.nabble.com/From-%22list%22-to-%22matrix%22-tp24345922p24345922.html
Sent from the R help mailing list archive at Nabble.com.
Try: do.call(rbind, vec) On Sun, Jul 5, 2009 at 4:10 PM, megh <megh700004@yahoo.com> wrote:> > Suppose, I have following > > vec <- vector("list", length=3) > for (i in 1:3) vec[[i]] <- matrix(rnorm((i+3)*2), (i+3)) > vec > > > Now I want to change the type of "vec" from list to a matrix with (4+5+6) > rows and 2 columns. How can I do that? > > Thanks and regards, > -- > View this message in context: > http://www.nabble.com/From-%22list%22-to-%22matrix%22-tp24345922p24345922.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
On Sun, 05-Jul-2009 at 12:10PM -0700, megh wrote:
|>
|> Suppose, I have following
|>
|> vec <- vector("list", length=3)
|> for (i in 1:3) vec[[i]] <- matrix(rnorm((i+3)*2), (i+3))
|> vec
|>
do.call("rbind", vec)
|>
|> Now I want to change the type of "vec" from list to a matrix
with (4+5+6)
|> rows and 2 columns. How can I do that?
|>
|> Thanks and regards,
|> --
|> View this message in context:
http://www.nabble.com/From-%22list%22-to-%22matrix%22-tp24345922p24345922.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.
--
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
___ Patrick Connolly
{~._.~} Great minds discuss ideas
_( Y )_ Average minds discuss events
(:_~*~_:) Small minds discuss people
(_)-(_) ..... Eleanor Roosevelt
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.