Skip to main content
eLearner.app

End of the R Course

Summary and final challenge

Congratulations: you have successfully completed the 3 modules of the R Course — from vector manipulation to data frame exploration, up to writing reusable functions and performing basic statistical analysis. Now, take on the final challenge to consolidate your learning!

Reminder: R exercises are verified statically (keywords). To actually run the code, each exercise provides a OneCompiler button that copies the code and opens the sandbox.

01 · Basics and Vectors

  • <-
  • c()
  • vector
  • logical
  • character
  • numeric
  • matrix

02 · Structures and Flow

  • data.frame
  • subsetting
  • $ operator
  • if / else
  • for loop

03 · Functions and Analysis

  • function()
  • return
  • mean()
  • median()
  • sd()
  • summary()

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 experiment freely, or use OneCompiler to run complex scripts.