Skip to main content

End of the R Course

Summary and final challenge

Congratulations: you have completed all 8 modules of the R Course — from atomic vectors and data frames to tidyverse, ggplot2, inferential statistics, lm() linear regression, and data pipelines. Take on the final challenge!

Exercises execute live in your browser using WebR (WebAssembly) alongside keyword and output verification; you can also test freely inside the R Playground.

01 · Bases and Vectors

  • <-
  • c()
  • recycling
  • coercion
  • logical
  • numeric
  • matrix

02 · Data Frame and Flow

  • data.frame
  • $
  • [r, c]
  • if / else
  • ifelse()
  • seq_along()

03 · Functions, Apply and Descriptive Statistics

  • function()
  • lapply()
  • sapply()
  • tapply()
  • na.rm
  • summary()

04 · Tidyverse and Pipeline dplyr

  • %>%
  • select()
  • filter()
  • mutate()
  • group_by()
  • summarise()

05 · Viewing with ggplot2

  • ggplot()
  • aes()
  • geom_point()
  • geom_col()
  • labs()
  • facet_wrap()

06 · Distributions and Statistical Inference

  • quantile()
  • rnorm()
  • t.test()
  • cor.test()
  • table()
  • chisq.test()

07 · Regression and Linear Models

  • lm()
  • y ~ x
  • summary()
  • predict()
  • residuals()
  • RMSE

08 · Advanced Wrangling and E2E Project

  • trimws()
  • gsub()
  • as.Date()
  • factor()
  • merge()
  • aggregate()

The final challenge, in three steps

Complete the R code snippets to create a data frame, iterate over data with a for loop, and implement a function for calculating the statistical mean.

1 · Creating a Data Frame

Create a data frame named store_data with two columns: products and sales. Module 2 (Data Frames).

Exercise#r.boss.e1
Attempts: 0Loading…

Define a data frame named store_data with a column products containing character values "A", "B", "C" and a column sales with numeric values 100, 250, 150.

Loading editor…
Show hint

Use the syntax: store_data <- data.frame(products = c("A", "B", "C"), sales = c(100, 250, 150))

Solution available after 3 attempts

2 · Iteration with a for loop

Run a loop to print numbers from 1 to 5. Module 2 (Conditionals and Loops).

Exercise#r.boss.e2
Attempts: 0Loading…

Write a for loop that iterates over the sequence 1 to 5 using the variable num and prints each value with print(num).

Loading editor…
Show hint

Use the syntax: for (num in 1:5) { print(num) }

Solution available after 3 attempts

3 · Writing a statistical function

Define a custom function that computes the mean. Module 3 (Writing Functions).

Exercise#r.boss.e3
Attempts: 0Loading…

Define the function analyze_vector that accepts an argument v and returns the mean of the elements computed via mean(v).

Loading editor…
Show hint

Use: analyze_vector <- function(v) { return(mean(v)) }

Solution available after 3 attempts

Printable Cheatsheet

A single page with all the essential syntax of R, ready to keep handy while you code.

Open the cheatsheet

What now?

Consistent practice is key. Open the R Playground to run scripts live in WebR or experiment freely.