Q:

Write a R program to convert a given matrix to a 1 dimensional array

0

Write a R program to convert a given matrix to a 1 dimensional array.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

m=matrix(1:12,3,4)
print("Original matrix:")
print(m)
a = as.vector(m)
print("1 dimensional array:")
print(a)

Sample Output:

[1] "Original matrix:"
     [,1] [,2] [,3] [,4]
[1,]    1    4    7   10
[2,]    2    5    8   11
[3,]    3    6    9   12
[1] "1 dimensional array:"
 [1]  1  2  3  4  5  6  7  8  9 10 11 12

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now