3MATRICES AND ARRAYS

image

By now, you have a solid handle on using vectors in R. A matrix is simply several vectors stored together. Whereas the size of a vector is described by its length, the size of a matrix is specified by a number of rows and a number of columns. You can also create higher-dimensional structures that are referred to as arrays. In this chapter, we’ll begin by looking at how to work with matrices before increasing the dimension to form arrays.

3.1 Defining a Matrix

The matrix is an important mathematical construct, and it’s essential to many statistical methods. You typically describe a matrix A as an m × n matrix; that is, A will ...

Get The Book of R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.