What will this line of code return?
Respond at pollev.com
.
01:00
In R, this evaluation happens element-wise when operating on vectors.
[1] TRUE TRUE FALSE
[1] FALSE FALSE TRUE
[1] TRUE TRUE FALSE
Which observations will be included in the following data frame?
Please respond at pollev.com
.
01:00
Which data frame will have fewer rows?
How do we extract the average of these students’ chance that class will be disrupted by a new COVID variant?
Let’s look at three different ways to answer this question
Cons
Pros
Cons
Pros
Cons
Pros
It’s good practice to understand the output of each line of code by breaking the pipe.
What are the dimensions (rows x columns) of the data frames output at each stage of this pipe?
01:00
What is will this line of code return?
Respond at pollev.com
.
Logical vectors have a dual representation as TRUE
FALSE
and 1
, 0
, so you can do math on logicals accordingly.
Taking the mean of a logical vector is equivalent to find the proportion of rows that are
TRUE
(i.e. the proportion of rows that meet the condition).
25:00
05:00
Let’s move to the lab slides on the course website!
25:00