Matrices
Explore the use of matrices in R, comparing them to data frames and understanding their homogeneous data type requirements. Learn to create matrices and apply matrix arithmetic including multiplication and inversion, enhancing your data manipulation skills in R.
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 |