R key terms and interview refresher
Use this section as a quick revision page before an interview or when a term comes up at work. The aim is to understand the idea well enough to explain it in plain language before memorising syntax.
VectorThe basic one-dimensional R structure. All elements in an atomic vector have the same basic type.
ListA flexible object that can contain items of different types, including vectors, data frames and other lists.
FactorA categorical variable stored with defined levels. Useful when categories have meaning or ordering.
Data frame vs tibbleBoth store tabular data. Tibbles are a tidyverse-friendly form with clearer printing and stricter behaviour.
NA vs NULL vs NaNNA means a missing value; NULL usually means absence of an object or element; NaN is a special numeric value meaning 'not a number'.
VectorisationApplying an operation to an entire vector or column instead of writing an explicit loop.
Pipe|> passes the result on the left into the next function, making multi-step workflows easier to read.
ReproducibilityThe ability for someone else, or future you, to rerun the same analysis and obtain the same result.
Common interview questions
What is the difference between a vector and a list in R?
A vector contains elements of one basic type. A list can contain objects of different types and sizes.
What is the difference between NA and NULL?
NA represents a missing value inside an object. NULL represents the absence of an object or element.
Why use factors?
Factors represent categorical variables and preserve a controlled set and order of levels, which matters in modelling and reporting.
What is the difference between a data frame and a tibble?
A tibble is a modern data-frame class with cleaner printing and fewer automatic conversions.
Why is vectorised code often preferred in R?
It is usually shorter, clearer and often faster than explicit loops for column- or vector-based operations.
Practical interview tests
These short tasks test whether you can apply the tool, explain your reasoning and validate the result. In a live exercise, say your assumptions aloud and check the output rather than rushing straight to syntax.
Summarise mean score and record count by category using dplyr.What it tests: grouped data manipulation
Answer: Use group_by() followed by summarise(), and handle missing values deliberately.
summary <- data |>
group_by(category) |>
summarise(
mean_score = mean(score, na.rm = TRUE),
records = n(),
.groups = "drop"
)
How would you find rows in one table with no match in another?What it tests: join validation
Answer: Use anti_join() when you want rows from the first table whose key does not occur in the second.
Why: anti_join() expresses the QA intention directly.
unmatched <- patients |>
anti_join(
hospitals,
by = "hospital_id"
)
What would you do before replacing NA values with a mean or median?What it tests: missing-data judgement
Answer: Investigate why values are missing, how many are missing, whether the pattern is systematic, and whether imputation is defensible.
Why: The interviewer is testing judgement, not whether you know one imputation function.
Convert score_2024, score_2025 and score_2026 into long format.What it tests: tidyr reshaping
Answer: Use pivot_longer() to create year and score columns.
long_data <- data |>
pivot_longer(
cols = starts_with("score_"),
names_to = "year",
values_to = "score"
)
When would you choose a Welch t-test rather than an equal-variance t-test?What it tests: statistical reasoning
Answer: Use Welch's test to compare two independent means when you do not want to assume equal population variances.
Why: In R, the ordinary two-sample t.test() uses Welch's approach by default unless var.equal = TRUE is supplied.