Skip to content
AgileLogics
Beginner 5 min read

Beginner Projects

Prerequisites: Level 1 — Beginner

Build these with what Level 1 covered — vectors, strings, conditionals, loops, functions, lists, and data frames. Write each as an R script and run it from RStudio or Positron.

1. Grade Calculator

Store students' names and scores in two vectors (or a data frame). Write a function that turns a score into a letter grade with if/else if, apply it to every student with sapply or vapply, and print each student's grade plus the class average.

2. Temperature Converter

Write c_to_f() and f_to_c() functions that work on whole vectors at once, then build a small conversion table as a data frame for -10°C to 40°C in steps of 5.

3. Dice Simulator

Simulate 1,000 rolls of two dice with sample(1:6, 1000, replace = TRUE), add them, count how often each total appears with table(), and find the most common total. Use set.seed(42) so your results are reproducible.

4. Shopping Basket

Keep a basket as a data frame with item, price, and quantity columns. Add a total column, print items costing more than 5, and print the basket total formatted with sprintf("%.2f", ...).

5. Password Strength Checker

Write a function that checks a password's length and whether it contains digits, uppercase letters, and symbols (using grepl), and returns "weak", "medium", or "strong".

6. Word Counter

Split a paragraph into lowercase words with strsplit and tolower, count them with table(), and print the five most common words with head(sort(counts, decreasing = TRUE), 5).