[R] Matrix column flip when recycled

arun smartpink111 at yahoo.com
Sun Jul 14 17:23:15 CEST 2013

M.1[,1:2]<-do.call(rbind,alply(replicate(3,M.2),3,function(x) x))



----- Original Message -----
From: Thiem Alrik <thiem at sipo.gess.ethz.ch>
To: "mailman, r-help" <r-help at r-project.org>
Sent: Sunday, July 14, 2013 9:48 AM
Subject: [R] Matrix column flip when recycled

Dear list,

I have a matrix M.1 (30x2) into which I would like to paste another matrix M.2 (10x2) three times. However, the columns get flipped in every odd-numbered recycle run. How can I avoid this behavior?

M.1 <- matrix(numeric(30*2), ncol = 2)
M.2 <- t(combn(1:5, 2))
M.1[, 1:2] <- M.2

Many thanks for help,


R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list