Skip to content
Prev 384048 / 398502 Next

The best way for making speciall matrix

Hi my friends,

I want to make the below matrix in r:

1 0 0 4

0 2 0 5

0 0 3 6

I used the below code:

matrix(c(1,0,0,0,2,0,0,0,3,4,5,6),nrow=3)

My code works. But I do not like my solution way. I am thinking to find the
simplest way for making this matrix. Do you think my code is the simplest
code for making this matrix? If not, could anyone writes a simpler code
than my one?