## Quiz 04: Policies and Information

### Location, Date, and Time

Conflicts: There will be no conflict quiz as students are able to choose the time and date of their quiz.

### Quiz Content

All quizzes are cumulative. Previous material can reappear on a later quiz.

3.3: Transforming Data

• Functions
• What is a function?
• What kinds of parameters exist?
• Why should we aim to write routines in the style of a function?
• How do other members of an open source community benefit from functions?
• Classes and Objects
• What does John Chamber’s mean by, “Everything that exists in R is an Object”?
• How does an object differ from a class?
• Vectorization
• How does vectorization work?
• Why does R prefer vectorized computations?
• When is recycling used in this calculations?
• What is the difference between a unary and binary operator? Provide examples of both.
• Explain how the modulus operator works.
• Subsets
• What are the different ways to subset data?
• What kind of positional indexing system does R use (0-based or 1-based)? Why does R use this kind of indexing system?
• How do the sequence generation techniques differ? How are they similar?
• What is the best way to form a sequence in R for positionally subsetting data?

4.2: Comparing Data

• Comparisons
• What kind of logical values exist?
• How are logical values similar to a reduced set of integers?
• Why is it said that %in% checks for “set” or “collection” membership?
• How do comparisons work with logical operators? Are all these comparisons vectorized?
• Logical Operators
• What kids of combining operations are possible?
• Why is it useful that computers perform “short-circuit” evaluation?
• How does the vectorized version of operators differ from the non-vectorized version?
• Why might we want to reduce a logical vector to a single logical value?
• Filtering Observations
• What are the differences between using the subset() function compared to bracket access, e.g. []?

4.3 / 5.1: Derived Variables

• Derived Variables
• What are derived variables?
• How can we create a derived variable?
• What are the different cases of derived variables?
• Control Statements
• How does a control structure differ from “flow of control?”
• What kinds of control structures exist? Which control structure do we often use the most?
• How is the vectorized version of if-else different from the unvectorized version?
• What are an alternative ways of writing an if-else if-else?
• How does a switch() perform when given a character input vs. integer input?

5.2: Data Oddities

• Vectors and Lists
• What is the difference between an atomic vector and a list?
• Why do classify an atomic vector and a list underneath a larger umbrella of “Vectors”?
• Why is list useful as a return type in a function?
• What is the difference between preserving and simplifying subsets.
• Coercion
• Why and when does coercion occur when working with R data types?
• How is implicit coercion different from explicit coercion?
• Why might we want to explicitly coerce data?
• Special Values
• What causes a value to fall under the category of special values?
• Provide examples of different special values found in R.
• Missingness
• Describe the different types of missing data.
• What type of missing data can be tested for?
• Why might we want to impute values for missing data instead of removing the observation?
• How do NULL and NA differ from each other? When should one be used over the other?

5.3: Loop-the-Loops

• Iteration:
• Why are computers good at iteration and humans aren’t?
• What kind of iteration structures exist in R?
• How does vectorization compare to an iteration structure?
• while loops:
• What happens in a while loop if the condition is always evaluating to TRUE?
• How are while loops useful to estimate numerically a solution?
• What issues arise with numeric numbers?
• for loops:
• How do for loops use sequences to process data?
• What are some drawbacks to supplying indices in a for loop?
• Why can you write a for loop as a while loop but not vice versa?
• How does a for loop select the data for a given iteration?
• repeat loops:
• Why is a repeat loop often referred to as a “do while” or running the computation at least once?
• Why does the repeat loop require break to exit it?
• Why can’t you always write a while loop as a repeat loop?
• When should repeat be used over while?

### Materials Needed

• Preferably, a rested mind and non-broken hands that can type.

### Policies

• All answers must be reasonably simplified.
• Decimals answers must contain two significant digits.
• Grading will be done as follows:

If you have a technical issue while answering questions or need assistance with opening or starting the quiz, please alert the proctor.

Do not leave the CBTF without filing an issue with the proctor if something goes wrong.

### DRES

Have a testing accommodation? Please see how the CBTF handles Letters of Accommodation.

The short version: Please bring a copy of the Letter of Accommodation to the CBTF Proctors prior to the test taking place.

In short, don’t cheat. Keep your eyes on your own quiz. Do not discuss the quiz with your friends after you have taken it. Any violation will be punished as harshly as possible.

The best way to study for a STAT 385 quiz is by writing and reading code. Try to take an idea in STAT 385 and apply it to your own work.

With this being said, there are three other resources that may assist your studies:

• Topic Outline (Above)
• Lecture Code
• Homework

Again, the best way to study is to do programming in some fashion. Whether that be writing code or explaining how code works to someone else.

Consider using resources such as:

1. RStudio Cloud Primers for interactive practice.
2. Exercise problems listed in a given section of the readings.

Do not spend time memorizing lecture slides. You will not see any verbatim questions.

Do not try pulling an all-nighter. You can schedule your quiz anytime between a time window. To program efficiently, you need sleep despite the quote:

“Programmers are an organism that turns caffeine into code.”

#### What kind of question types are on the quiz?

There are generally four types of problems:

• True / False
• Multiple Selection (e.g. select ALL correct answers from a list)
• Fill in the blank
• Writing Code

#### How many problems are on the quiz?

Only one question with 15012391 subquestions. In all seriousness, do not fixate on a number. There will be a reasonable amount of questions for the time period.

#### How long will it take to do the quiz?

Depending on your background, the quiz may take:

• Prior R in-depth experience: 25 minutes
• Some R experience: 35 minutes
• No R experience: 50 minutes

Avoid fixating on time. Life will come and go more quickly than you realize. Focus more on the content.

#### When will the quiz be returned?

As all problems are automatically graded, we should be able to post the quiz results after the examination window closes.

No.

#### We got our grades back, now will the quiz be curved?

No. Curving is only done sparingly at the end of the semester. Individual assignments are not modified.