Write a R program to concatenate two given matrixes of same column but different rows.
x = matrix(1:12, ncol=3) y = matrix(13:24, ncol=3) print("Matrix-1") print(x) print("Matrix-2") print(y) result = dim(rbind(x,y)) print("After concatenating two given matrices:") print(result)
Sample Output:
[1] "Matrix-1" [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 [1] "Matrix-2" [,1] [,2] [,3] [1,] 13 17 21 [2,] 14 18 22 [3,] 15 19 23 [4,] 16 20 24 [1] "After concatenating two given matrices:" [1] 8 3
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
[1] "Matrix-1" [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 [1] "Matrix-2" [,1] [,2] [,3] [1,] 13 17 21 [2,] 14 18 22 [3,] 15 19 23 [4,] 16 20 24 [1] "After concatenating two given matrices:" [1] 8 3need an explanation for this answer? contact us directly to get an explanation for this answer