Q:

Write a R program to convert a given matrix to a list

0

Write a R program to convert a given matrix to a list.

All Answers

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

m = matrix(1:10,nrow=2, ncol=2)
print("Original matrix:")
print(m)
l = split(m, rep(1:ncol(m), each = nrow(m)))
print("list from the said matrix:")
print(l)

Sample Output:

[1] "Original matrix:"
     [,1] [,2]
[1,]    1    3
[2,]    2    4
[1] "list from the said matrix:"
$`1`
[1] 1 2

$`2`
[1] 3 4

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