Quiz Demo

Test your R knowledge with interactive coding challenges.

NoteLearning Objectives
  • Practice writing R expressions and functions
  • Work with vectors, data frames, and basic statistics
  • Get immediate feedback by running your code in the browser

Knowledge Check

Write your answers in the code editors below and click Run Code to check your work. Expand the answer sections if you get stuck.


Question 1: Sequences

What function in R creates a sequence of integers from 1 to 10?

1:10
# or
seq(1, 10)

Question 2: Summary Statistics

Using base R, calculate the mean of the vector c(4, 8, 15, 16, 23, 42).

mean(c(4, 8, 15, 16, 23, 42))
# Answer: 18

Question 3: Data Frames

Create a data frame with two columns: name (with values β€œAlice”, β€œBob”, β€œCarol”) and score (with values 90, 85, 92). Then filter to only rows where score > 88.

df <- data.frame(
  name = c("Alice", "Bob", "Carol"),
  score = c(90, 85, 92)
)
df[df$score > 88, ]