What does `matrix(data, nrow, ncol)` create in R?
A matrix filled from `data` with the specified numbers of rows and columns.
What operations are permitted between vectors of different dimensions?
Matrix multiplication with `%*%` is permitted.
What does `matrix(4, 3, 3)` create in R?
A 3-by-3 matrix whose entries are all 4.
When is vector multiplication with `%*%` valid?
When the dimensions permit the matrix product.
What does a data frame resemble, and what can its columns contain?
It resembles a matrix, and its columns can contain different data types.
Which R operators mean logical AND, logical OR, equality, and inequality?
&, |, ==, and !=, respectively.
Which matrix names do `colnames(x)` and `rownames(x)` assign in R?
`colnames(x)` assigns column names; `rownames(x)` assigns row names.
Which function creates a data frame in R?
`data.frame()`.
How do R's !, &, |, &&, and || operators differ in behavior?
! negates; & and | operate element by element, while && and || use only the first elements and are recommended for scalars.
Answer 8 questions on R Matrices and Data Structures.
1. In R, you need a matrix with 2 rows and 3 columns populated from the vector `c(8, 5, 1, 4, 7, 9)`. Which command creates it with those dimensions?
2. For a matrix `M` with at least 4 rows and 3 columns, which expression selects its entire fourth row?
Go over the full study guide for R Matrices and Data Structures.
Read the study guide →Upload your class notes and Revizly writes your flashcards in about a minute.
Flashcard maker