2 Combining Vectors
Another method for creating matrices is to combine a number of vectors, either by row or by column. Consider the following matrix that has been divided according to its columns:
We can easily construct two vectors using the c command that contains the values in each of the matrix’s columns.
To form matrix D, the cbind command combines vectors of equal length such that each makes one of the matrix’s columns.
Alternatively, consider matrix E that has been divided according to its rows:
|
|
|
|
|
Once again it is simple to construct three vectors containing the values within each row.
-
-
-
-
To form matrix E, the rbind command combines vectors of equal length such that each makes one of the matrix’s rows.
-
E <- rbind(row1, row2, row3, row4)
-