# An array with one dimension with values ranging from 1 to 24
thisarray <- c(1:27)
thisarray
# An array with more than one dimension
multiarray <- array(thisarray, dim = c(3, 3, 3))
multiarray
thisarray <- c(1:24)
# Access all the items from the first row from matrix one
multiarray <- array(thisarray, dim = c(4, 3, 2))
multiarray[,1,1]
# Access all the items from the first column from matrix one
multiarray <- array(thisarray, dim = c(4, 3, 2))
multiarray[1,,1]
thisarray <- c(1:24)
multiarray <- array(thisarray, dim = c(4, 3, 2))
5 %in% multiarray
# Create two vectors of different lengths.
vector1 <- c(5,9,3)
vector2 <- c(10,11,12,13,14,15)
# Take these vectors as input to the array.
result <- array(c(vector1,vector2),dim = c(3,3,2))
result
# Create two vectors of different lengths.
vector1 <- c(5,9,3)
vector2 <- c(10,11,12,13,14,15)
[Link] <- c("COL1","COL2","COL3")
[Link] <- c("ROW1","ROW2","ROW3")
[Link] <- c("ROW1","ROW2","ROW3")
[Link] <- c("Matrix1","Matrix2")
# Take these vectors as input to the array.
result <- array(c(vector1,vector2),dim = c(3,3,2),dimnames =
list([Link],[Link],
[Link]))
result
Create two vectors of different lengths.
vector1 <- c(5,9,3)
vector2 <- c(10,11,12,13,14,15)
# Take these vectors as input to the array.
array1 <- array(c(vector1,vector2),dim = c(3,3,2))
# Create two vectors of different lengths.
vector3 <- c(9,1,0)
vector4 <- c(6,0,11,3,14,1,2,6,9)
array2 <- array(c(vector1,vector2),dim = c(3,3,2))
# create matrices from these arrays.
matrix1 <- array1[,,2]
matrix2 <- array2[,,2]
# Add the matrices.
result <- matrix1+matrix2
result
# Create two vectors of different lengths.
vector1 <- c(5,9,3)
vector2 <- c(10,11,12,13,14,15)
# Take these vectors as input to the array.
[Link] <- array(c(vector1,vector2),dim = c(3,3,2))
([Link])
Fee Faysal Ahmed, Dept. Of Mathematics9:55 PM
# Use apply to calculate the sum of the rows across all the
matrices.
result <- apply([Link], 1, sum)
(result)