Q:

Write a R program to create an 3 dimensional array of 24 elements using the dim() function

0

Write a R program to create an 3 dimensional array of 24 elements using the dim() function.

All Answers

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

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

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