To find the first element of an array in R, we can use indexing. In R, arrays are created using the array()
function, and indexing starts from 1 instead of 0.
Here's a simple example:
main.r161 chars9 lines
The result will be:
main.r6 chars2 lines
In the example, we created a 3-dimensional array with dimension 3 x 4 x 1
. We then used indexing to get the first element of the array, which is located at index [1, 1, 1]
. We stored the result in the variable 'first_element' and printed it to the console.
gistlibby LogSnag