Reputation: 193
let's say i got x=seq(0,1,0.2)
and y=x[1:2]
.
How do I say that a given matrixes, e.g. z=matrix(0,10,10)
, first 2 inputs in the first column should be the ones from y?. So I want to be y a part of z (if that makes sense).
I tried z[[1:2],1]=y
but this doesn't work.
How do I do that neatly without any loops?
Thank you!
Upvotes: 1
Views: 75
Reputation: 101373
Since the length of y
is less than the number of rows of z
, you can use
z[1:2] <- y
since values are assigned by columns from left to right
Upvotes: 1