7  Lecture: R Basics

7.1 R Basics lecture

Here’s a recording of this lecture (48 minutes 14 seconds):

Recording

7.2 R Basics slides

PDF slide set

7.3 Questions

7.3.1 Question 1

What does a <- 9; a < - 9 do?

7.3.2 Question 2

Given a vector x of length 10, which of the following R code snippets would remove the third element from the vector and assign the result to a new vector y? More than one option may be correct.

7.3.3 Question 3

Given the following vector:

x <- c(a = 1, b = 2, c = 3)

Which of the following R code snippets will extract only the element corresponding to the name “b”?

7.3.4 Question 4

Given the following R code:

x <- 1:6
dim(x) <- c(2, 3)

Which of the following options correctly extracts the second column of the matrix x as a column vector?

7.3.5 Question 5

Which of the following statements are true about data frames in R?