## R Matrix Example

By ganpati | R Programming

matrix

What it does?

It creates a matrix with the given data, number of rows and number of columns, either row wise or column wise

Syntax:

matrix ( vector of values, number of rows, number of columns, by row/column)

Example:

matrix (c(1,2,3,4,5,6), nrow=2, ncol=3, byrow=TRUE)

1 2 3

4 5 6