i

R Programming Complete Tutorial

R Array Construction

Multi-Dimensional Data

R arrays are the data objects, which can store data in more than two dimensions.

Create an Array

An array is created using array functions.Data is the input vector of similar data types.Dim defines the number of rows, columns, and matrices of the array.And dim name allows us to name rows, columns, and matrices in an array.

Array Syntax:

We can construct any array using data and dimensions. In this example, we are taking a vector of elements from 1 to 6. In the dim, the first 2 is for rows, and the next 3 is for the number of columns and the last 2 for no of matrices. So, this function will construct an array of 2 matrices with 2 rows and 3 columns, when we construct things in R, it will be displayed like this.

Array Construction: