In R, you can create a three-dimensional list using nested lists, where each inner list represents a 2D plane within the 3D structure.
In this example,
matrix_3d <- list(
list(c(1, 2), c(3, 4)),
list(c(5, 6), c(7, 8)),
list(c(9, 10), c(11, 12))
)
print(matrix_3d)
[[[1, 2], [3, 4]], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]
In this example,
matrix_3d <- list(
list(c('a', 'b'), c('c', 'd')),
list(c('e', 'f'), c('g', 'h'))
)
print(matrix_3d)
[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]
In this tutorial, we learned How to create a Three Dimensional List in R language with well detailed examples.