R Matrices and Data Structures Flashcards (9 cards)

All cards

1Question

What does `matrix(data, nrow, ncol)` create in R?

Answer

A matrix filled from `data` with the specified numbers of rows and columns.

2Question

What operations are permitted between vectors of different dimensions?

Answer

Matrix multiplication with `%*%` is permitted.

3Question

What does `matrix(4, 3, 3)` create in R?

Answer

A 3-by-3 matrix whose entries are all 4.

4Question

When is vector multiplication with `%*%` valid?

Answer

When the dimensions permit the matrix product.

5Question

What does a data frame resemble, and what can its columns contain?

Answer

It resembles a matrix, and its columns can contain different data types.

6Question

Which R operators mean logical AND, logical OR, equality, and inequality?

Answer

&, |, ==, and !=, respectively.

7Question

Which matrix names do `colnames(x)` and `rownames(x)` assign in R?

Answer

`colnames(x)` assigns column names; `rownames(x)` assigns row names.

8Question

Which function creates a data frame in R?

Answer

`data.frame()`.

9Question

How do R's !, &, |, &&, and || operators differ in behavior?

Answer

! negates; & and | operate element by element, while && and || use only the first elements and are recommended for scalars.

Test yourself with the quiz

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?

Take the quiz →

Read the study guide

Go over the full study guide for R Matrices and Data Structures.

Read the study guide →

Related classes

Make your own flashcards

Upload your class notes and Revizly writes your flashcards in about a minute.

Flashcard maker