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):
- R → https://cran.r-project.org/
- 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):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# This is a comment — computer ignores it print("Hello, I am learning R in 2026! 🎉") # Simple math 5 + 3 10 * 4.2 2 ^ 10 # 2 power 10 sqrt(144) # square root |
You should see answers appear in the console.
Example 2: Variables (storing values)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
name <- "Webliance" # use <- or = (both work, <- is more R-style) age <- 25 height <- 1.72 is_student <- TRUE print(name) print(age + 5) # Check type class(name) # "character" class(age) # "numeric" class(is_student) # "logical" |
Example 3: The Most Important Thing in R → Vectors
Vectors are like lists of numbers (or words).
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Numeric vector marks <- c(78, 92, 65, 88, 71) # Character vector subjects <- c("Maths", "Stats", "R Prog", "Python", "Excel") # Logical vector passed <- c(TRUE, TRUE, FALSE, TRUE, TRUE) # Operations on whole vector at once — this is magic in R! marks + 5 # adds 5 to every mark marks * 2 mean(marks) # average = 78.8 max(marks) # 92 summary(marks) # min, max, mean, median, quartiles — super useful! |
Example 4: Data Frame — Excel Table in R
This is where R becomes really powerful.
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Create a small table students <- data.frame( Name = c("Amit", "Priya", "Rahul", "Sneha"), Age = c(22, 21, 24, 23), Marks = c(85, 92, 68, 79), Passed = c(TRUE, TRUE, FALSE, TRUE) ) # Look at it print(students) # View nicely (better in RStudio) View(students) # Get column students$Marks # Average marks mean(students$Marks) # Filter — only students who passed students[students$Passed == TRUE, ] # Add new column students$Grade <- ifelse(students$Marks >= 80, "A", "B") print(students) |
Output looks like:
|
0 1 2 3 4 5 6 7 8 9 10 |
Name Age Marks Passed Grade 1 Amit 22 85 TRUE A 2 Priya 21 92 TRUE A 3 Rahul 24 68 FALSE B 4 Sneha 23 79 TRUE B |
Example 5: Quick Beautiful Plot (base R)
|
0 1 2 3 4 5 6 7 8 9 10 11 |
# Simple scatter plot plot(students$Age, students$Marks, main = "Age vs Marks", xlab = "Age (years)", ylab = "Marks", pch = 16, col = "blue") # pch=16 → filled circles |
But the real magic starts when you learn ggplot2 (most popular plotting package).
Install it once:
|
0 1 2 3 4 5 6 |
install.packages("ggplot2") |
Then:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 |
library(ggplot2) ggplot(students, aes(x = Age, y = Marks, color = Passed)) + geom_point(size = 4) + theme_minimal() + labs(title = "Age vs Marks by Pass Status", x = "Age", y = "Marks") |
This plot looks publication-ready!
4. Typical Learning Path (What to Learn Next — Suggested Order)
- Basics (vectors, data.frames, $, mean(), summary())
- Installing & using packages (install.packages(), library())
- Import data (read.csv(), readxl::read_excel())
- Clean data → dplyr package (filter, select, mutate, group_by, summarise)
- Visualization → ggplot2
- Basic statistics → t.test(), lm() regression, cor()
- R Markdown / Quarto → make beautiful reports (very important in 2026!)
- 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! 🚀
