Skip to course content
Free R data course

R Foundations for Data Analysis

Module 02 Knowledge Check

5 questions. Pass mark 4 out of 5. Answer every question before checking the answer key below, then retry after reading the feedback.

1. x <- 5 and x < -5 differ because…

2. A good comment on a line that removes values of 9999 says…

3. visits + c(1, 2, 3, 4) where visits has six elements…

4. The correct way to test whether a value is missing is…

5. mean(scores) returns NA on a column with one gap because…

---

Answer Key and Explanations

Check these only after attempting every question.

1. B — the first assigns and the second compares

One space changes assignment into comparison, and R reports no error either way.

2. B — that 9999 is the source system's not-recorded sentinel

The code already says what happens. The comment carries what the code cannot: what the value means.

3. C — warns about lengths and still returns a result

R warns because 6 is not a multiple of 4, but a result still comes back — which is why a recycling warning should be treated as an error.

4. B — is.na(x)

NA is unknown, so x == NA returns NA for every row and no row passes the filter — it looks like there is no missing data.

5. B — na.rm defaults to FALSE

Defaults are decisions the function makes for you. R refuses to average around a hole unless you say so.

Practical Check

Apply this module to your own work: complete the module activity for *R Language Basics*, then write one sentence naming what your result shows and one naming what it does not.

Strong Answer Pattern

A strong answer names the task, the evidence used, the check performed, and the remaining limitation. It avoids "proved", "guaranteed", or "always" unless the evidence genuinely supports it.