EDITED:
I would like to efficiently create a 1452 x 44 matrix, where:
How can I do this in R? Many thanks in advance!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.