+ 1
R
Iâm using R language. Can someone please tell me how it get the number â 1,3,5â and â2,4,6â ? x <- matrix(c(1,2,3,4,5,6), nrow = 2, ncol = 3) print(x) [,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6
12 RĂ©ponses
+ 4
The argument specifies that the matrix should have 2 rows, and the byrow = FALSE argument indicates that the values should be filled column-wise.
+ 3
M <- matrix(c(1:6), nrow = 2, byrow = FALSE )
print(M)
#access first row
print(M[1,])
#access second row
print(M[2,])
+ 3
@Phirun Chhay
Did this fix your problem?
The argument specifies that the matrix should have 2 rows, and the byrow = FALSE argument indicates that the values should be filled column-wise.
+ 1
Phirun Chhay
you mean how to create the matrix?
it is in my first line.
There are many ways to create a matrix, but it is important to specify how it is created.
The default is byrow=FALSE
so if you do not specify anything, it is filled column wise
+ 1
Yes I get it now. Ty
0
So what exactly are you trying to do here?
0
Sorry I missed this part ->
x <- matrix(c(1,2,3,4,5,6), nrow = 2, ncol = 3)
print(x)
0
What language are you using for this?
Sorry if this is a dumb question... I am new but eh at coding.
0
Iâm using R
0
Ok, give me one second, I may be able to figure this out.
0
Bob_Li I know that access first and second row but I wanna know how it calculated to get those number.
0
Phirun Chhay
No problem!