...

/

Matrices

Matrices

In this lesson, we will discuss matrices.

Matrices are R objects where elements are arranged in a two-dimensional rectangular layout.

Like arrays, they contain elements of the same data type.

Creating Matrices

A Matrix is created using the matrix() function. The matrix() function takes an atomic vector as input. We can also define how many rows should be in the matrix by setting the nrow argument to a number. Furthermore, we can also set the ncol argument, which tells R how many columns to ...