+ 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

11th May 2023, 3:50 AM
Phirun Chhay
12 odpowiedzi
+ 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.
11th May 2023, 4:12 AM
RJbologna
RJbologna - avatar
+ 3
M <- matrix(c(1:6), nrow = 2, byrow = FALSE ) print(M) #access first row print(M[1,]) #access second row print(M[2,])
11th May 2023, 4:09 AM
Bob_Li
Bob_Li - avatar
+ 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.
11th May 2023, 4:17 AM
RJbologna
RJbologna - avatar
+ 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
11th May 2023, 4:13 AM
Bob_Li
Bob_Li - avatar
+ 1
Yes I get it now. Ty
11th May 2023, 4:20 AM
Phirun Chhay
0
So what exactly are you trying to do here?
11th May 2023, 4:02 AM
RJbologna
RJbologna - avatar
0
Sorry I missed this part -> x <- matrix(c(1,2,3,4,5,6), nrow = 2, ncol = 3) print(x)
11th May 2023, 4:04 AM
Phirun Chhay
0
What language are you using for this? Sorry if this is a dumb question... I am new but eh at coding.
11th May 2023, 4:05 AM
RJbologna
RJbologna - avatar
0
I’m using R
11th May 2023, 4:06 AM
Phirun Chhay
0
Ok, give me one second, I may be able to figure this out.
11th May 2023, 4:07 AM
RJbologna
RJbologna - avatar
0
Bob_Li I know that access first and second row but I wanna know how it calculated to get those number.
11th May 2023, 4:11 AM
Phirun Chhay
0
Phirun Chhay No problem!
11th May 2023, 4:21 AM
RJbologna
RJbologna - avatar