佄佲 侁伝 wrote:
> Hi,
> I have created a matrix and initially all elements in the matrix was
> assigned to NA.Then I want to assign values to some elements of this
> matrix. Can I use formation like matrix[i][j] <- 4?if not, how can i do
> this? now I have three vectors
> y1 y2 y3
> 3 4 3.1
> 5 2 4.2
> if I want to assign y3's value to matrix, where the value's row and
> column should correspond the y1's and y2's value, such like
> matrix[y1[1]][y2[1]] <- y3[1]
For a matrix X:
X[cbind(y1, y2)] <- y3
Uwe Ligges
> how can this be realized?
> thanks
> Hao Wu
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html