Which of the following expressions will generate the following matrix?
\[ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{bmatrix} \]
- Wrong. This command will return \[\begin{bmatrix} 1 & 3 & 5 \\ 2 & 4 & 6 \\ \end{bmatrix}\]
- Wrong. This command will return \[\begin{bmatrix} 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\ \end{bmatrix}\]
- Correct.
- Wrong. This command will return \[\begin{bmatrix} 6 & 6 \\ 6 & 6 \\ 6 & 6 \\ \end{bmatrix}\]
- Wrong. This command will return \[\begin{bmatrix} 6 & 6 & 6 \\ 6 & 6 & 6 \\ \end{bmatrix}\]
Which of the following expressions will convert matrix \(a\) into matrix \(b\)?
\[ \begin{align*} a &= \begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \\ \end{bmatrix} \\ b &= \begin{bmatrix} 1 & 2 \\ 3 & 5 \\ 4 & 6 \\ \end{bmatrix} \end{align*} \]
- Wrong. This command will produce an error since we’re trying to overwrite columns that don’t exist.
- Wrong. This command will produce an error since we’re trying to overwrite rows that don’t exist.
- Wrong. This command will produce \[\begin{bmatrix} 1 & 2 \\ 4 & 4 \\ 5 & 5 \\ \end{bmatrix}\]
- Wrong. This command will produce \[\begin{bmatrix} 1 & 2 \\ 3 & 4 \\ 5 & 6 \\ \end{bmatrix}\]
- Correct.
Which of the following statements most accurately describes the relationship between an R matrix and an R vector?
A matrix’s underlying data is stored exactly like a vector’s. What makes a matrix different is the addition of a dim attribute that tells R to interpret the sequence of underlying data as having rows and columns. You can convert a vector to a matrix by adding a dim attribute, and you can convert a matrix back to a vector by removing the dim attribute.