Conditional Statements
- Write an
if
statement to select between expressions based on a condition.
- Use the correct syntax for an
if
statement in R.
- Given the components of a condition and an
if
statement, determine the output produced by R.
- Write a “compound” condition using the comparison and logical operators.
- Use the “twin” logical operators
&&
and ||
to construct a condition.
- Explain what it means that the “twin” logical operators evaluate lazily.
- Write
if
, if
-else
, and if
-else if
-else
statements.
Iteration
for
- Explain how a
for
loop can simplify code.
- Write a
for
loop to perform an indicated sequence of commands in R.
- Use the correct syntax for a
for
loop in R.
- Given a
for
loop, determine the outputs stored in each variable within the loop after the loop has completed.
while
- Explain how a
while
loop differs from a for
loop.
- Write a
while
loop to perform an indicated sequence of commands in R.
- Use the correct syntax for a
while
loop in R.
- Given a
while
loop, determine the outputs stored in each variable within the loop after the loop has terminated.
- Describe situations where a
while
loop or for
loop is preferred.
- Use
show
to make the innards of a loop transparent.
Vectorization
- Explain what it means for a function to be vectorized.
- Describe the benefits of using vectorized functions.