i

R Programming Complete Tutorial

Accessing Array Elements

We can access any element using its indexing by number and name. First, we will focus on a number based indexing.

Access element by position (index):

We already have an array with 2 matrices. We can access any element by its position. We use a single square bracket "[ ]" for indexing. The first position is for the row, 2nd position is for the column, and 3rd one is for Matrix. If we use [2, 2, 1], it means; first, it will select 1st Matrix, in that Matrix, it will go to 2nd row and finally select the 2nd column.  

Access the elements by names:

We can also access any element by the appropriate names of Matrix, row, and column.