1. Defining matrices. The function matrix(x, nrow, ncol)
can be used to create a matrix object in R
.
The nrow
and ncol
parameters specify the number of rows and columns of the matrix. Additionally, x
is a vector of values that is transformed into the matrix.
Start by defining a variable, vector
, that consists of the integers from 1 to 20 using 1:20
. Use matrix()
to transform that variable into a 4x5 matrix.