In this video we continue to discuss subscripts, this time concentrating on matrices and arrays. Each dimension of these structures may be subscripted to return a sub-matrix or sub-array of the original structure. In addition, we show how to subscript a matrix with a matrix of logicals or with a vector of indices. We also discuss R's default behavior of dropping a dimension of the subscripted object when subscripts select only one level of one of its dimensions. This behavior is often unknown to inexperienced R programmers and can cause problems, especially in code that operates on matrices with matrix algebra. We introduce the drop= option to suppress the dimension-dropping behavior. While watching this video
you should open
Mod10Script.R and follow along with Example 7.
This video covers fundamental material of great importance for R
programming. If you have some prior experience with R, some of the
content here may be a review for you, but I strongly encourage you to watch this video anyway.