R Tutorial

What actually is R?

R is a free, open-source programming language that was specifically created for:

  • Doing statistics
  • Analyzing data
  • Making beautiful charts & graphs
  • Doing machine learning (to some extent)
  • Preparing reports that look professional

It was born in 1993 by two professors in New Zealand (Ross Ihaka + Robert Gentleman). That’s why it’s called R — just the next letter after S (there was an older language called S).

Today (2026), R is still one of the top 2–3 most used languages in data science, side by side with Python.

Quick comparison most people ask:

Feature R Python
Best for Statistics, publication plots General purpose + ML
Data frame handling Excellent (built-in) Excellent (via pandas)
Beautiful plots ggplot2 is legendary matplotlib / seaborn good
Learning curve (stats) Easier if you know statistics Easier if you know programming
Speed (big data) Slower unless you use packages Faster with numpy / polars
Community (2026) Still very strong in academia Bigger overall

2. Okay… but what is an “R Tutorial”?

An R tutorial is simply a guided set of lessons that teach you how to write instructions (code) in the R language so your computer can:

  • Read your Excel/CSV files
  • Clean messy data
  • Calculate averages, correlations, t-tests, regressions…
  • Make graphs that look like they came from a scientific paper
  • Automate repetitive analysis

Think of it as learning “Excel formulas on steroids” — but much more powerful and reproducible.

3. Let’s Start Writing Real R Code (Hands-on Examples)

First thing — install two things (do this now if you haven’t):

  1. R → https://cran.r-project.org/
  2. RStudio (the best editor) → https://posit.co/download/rstudio-desktop/ (free version)

Once installed → open RStudio.

You will see 4 panels:

  • Top-left: Script (where you write code)
  • Bottom-left: Console (where code runs)
  • Top-right: Environment + History
  • Bottom-right: Files / Plots / Packages / Help

Example 1: Your First Line — Hello World + Simple Math

In the console (or better — in a new script) type and press Ctrl+Enter (or Run button):

R

You should see answers appear in the console.

Example 2: Variables (storing values)

R

Example 3: The Most Important Thing in R → Vectors

Vectors are like lists of numbers (or words).

R

Example 4: Data Frame — Excel Table in R

This is where R becomes really powerful.

R

Output looks like:

text

Example 5: Quick Beautiful Plot (base R)

R

But the real magic starts when you learn ggplot2 (most popular plotting package).

Install it once:

R

Then:

R

This plot looks publication-ready!

4. Typical Learning Path (What to Learn Next — Suggested Order)

  1. Basics (vectors, data.frames, $, mean(), summary())
  2. Installing & using packages (install.packages(), library())
  3. Import data (read.csv(), readxl::read_excel())
  4. Clean data → dplyr package (filter, select, mutate, group_by, summarise)
  5. Visualization → ggplot2
  6. Basic statistics → t.test(), lm() regression, cor()
  7. R Markdown / Quarto → make beautiful reports (very important in 2026!)
  8. Advanced → tidyr, stringr, lubridate, shiny (interactive apps)

Final Small Advice from Your “Human Teacher”

  • Don’t try to memorize everything.
  • Type code yourself — don’t just copy-paste.
  • Make small mistakes → fix them → that’s how you really learn.
  • Do tiny real projects: analyze your own exam marks, cricket scores, monthly expenses, movie ratings…
  • When stuck → Google: “how to [something] in R” — 99% of answers are on Stack Overflow.

You want to continue?

  • Shall we do a mini-project together (like analyze sample sales data)?
  • Or go deeper into dplyr?
  • Or install R + RStudio step-by-step?

Just tell me where you want to go next! 🚀