Write a R program to create an 3 dimensional array of 24 elements using the dim() function.
v = sample(1:5,24,replace = TRUE) dim(v) = c(3,2,4) print("3-dimension array:") print(v)
Sample Output:
[1] "3-dimension array:" , , 1 [,1] [,2] [1,] 4 2 [2,] 4 2 [3,] 2 1 , , 2 [,1] [,2] [1,] 4 2 [2,] 2 4 [3,] 2 4 , , 3 [,1] [,2] [1,] 4 2 [2,] 1 5 [3,] 3 2 , , 4 [,1] [,2] [1,] 3 3 [2,] 1 5 [3,] 1 2
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] "3-dimension array:" , , 1 [,1] [,2] [1,] 4 2 [2,] 4 2 [3,] 2 1 , , 2 [,1] [,2] [1,] 4 2 [2,] 2 4 [3,] 2 4 , , 3 [,1] [,2] [1,] 4 2 [2,] 1 5 [3,] 3 2 , , 4 [,1] [,2] [1,] 3 3 [2,] 1 5 [3,] 1 2need an explanation for this answer? contact us directly to get an explanation for this answer