Page 235 - Data Science class 11
P. 235
result <- array(c(vector1,vector2),dim = c(3,3,2),dimnames = list(row.names,column.
names,
matrix.names))
print(result)
The print statement will cause the following to be displayed:
6.10.2 accessing array elements
Example
Enter the following code snippet:
# Creating two vectors of different lengths.
vector1 <- c(4,8,3)
vector2 <- c(11,12,13,14,15,16)
column.names <- c("COL1","COL2","COL3")
row.names <- c("ROW1","ROW2","ROW3")
matrix.names <- c("Matrix1","Matrix2")
# Taking these vectors as input to the array.
result <- array(c(vector1,vector2),dim = c(3,3,2),dimnames = list(row.names,
column.names, matrix.names))
# Printing the third row of the second matrix of the array.
print(result[3,,2])
# Printing the element in the 1st row and 3rd column of the 1st matrix.
print(result[1,3,1])
# Printing the 2nd Matrix.
print(result[,,2])
Programming with R 233

