Slip28
Write an R program to convert a given matrix to a list and print list in
ascending order.
sorted_list <- sort(list_from_matrix)
print(sorted_list)
sorted_list <- sort(list_from_matrix)
print(sorted_list)
Output
> m <- matrix(1:9, nrow = 3)
>
> list_from_matrix <- matrix_to_list(m)
>
> # Print the list in ascending order
> sorted_list <- sort(list_from_matrix)
> print(sorted_list)
[1] 1 2 3 4 5 6 7 8 9
>
> list_from_matrix <- matrix_to_list(m)
>
> # Print the list in ascending order
> sorted_list <- sort(list_from_matrix)
> print(sorted_list)
[1] 1 2 3 4 5 6 7 8 9