Matrices
Learn to use matrices in R, how they’re different from data frames, and how to do matrix arithmetic.
We'll cover the following...
Matrices in R are very similar to data frames, but they’re less commonly used. In a data science context, they can be helpful in specific scenarios, but the vast majority of the time it’s easier to use data frames.
Comparing data frames and matrices
The main difference between matrices and data frames is that matrices must be of a homogenous data type. So, while data frames can contain various data types, as in the examples in the previous lesson, matrices must only have one data type. However, because of that constraint, we can use matrices to perform matrix arithmetic, which will be helpful from time to time.
Matrix | Data Frame |
---|---|
Tabular data storage |