Reputation: 77
EDITED:
I would like to efficiently create a 1452 x 44 matrix, where:
How can I do this in R? Many thanks in advance!
Upvotes: 1
Views: 127
Reputation: 145835
After edits, moving my comment to an answer:
x1 = 44
x2 = 1452
m = matrix(c(rep(rep(0:1, c(x1, x2)), x2 / x1 - 1), rep(0, x1)),
ncol = x2 / x1)
Essentially, you want a pattern of 44 0s then 1452 1s repeated a bunch. We stick on the last set of 44 0s so it ends on 0 and set the dimensions accordingly.
Upvotes: 2