</>
CodeLearn Pro
Start Learning Free β†’
R programming data science background
Data Science & AI Β· Intermediate Β· Statistical Computing

Learn R

The language of statisticians, data scientists and researchers. R turns raw data into insight β€” with built-in statistics, powerful data frame manipulation, and ggplot2 charts that look publication-ready from day one.

πŸ“Š
Built for Data
Designed from the ground up for statistics, analysis and visualisation
πŸ“ˆ
ggplot2
The most powerful data visualisation library in any language
πŸ”¬
Academic Standard
The language of choice in universities, research labs and data science
πŸ“¦
CRAN Packages
20,000+ packages for every statistical and machine learning task

R at a Glance

Statistical power built into the language. Analyse data with less code than any other tool.

vectors.R
R
# Create a numeric vector
scores <- c(85, 92, 78, 95, 88, 76, 91)

# Basic statistics β€” built right in
print(mean(scores))    # average
print(median(scores))  # middle value
print(sd(scores))      # standard deviation
print(range(scores))   # min and max

# Vector operations are element-wise
doubled <- scores * 2
print(doubled)

# Logical filtering
passed <- scores[scores >= 80]
print(passed)

> source("vectors.R")

[1] 86.43
[1] 88
[1] 6.80
[1] 76 95
[1] 170 184 156 190 176 152 182
[1] 85 92 95 88 91
dataframe.R
R
# Create a data frame
students <- data.frame(
  name  = c("Alice", "Bob", "Carol", "Dave"),
  score = c(92, 78, 95, 85),
  grade = c("A", "C", "A", "B"),
  stringsAsFactors = FALSE
)

print(students)

# Access a column with $
print(students$name)

# Filter rows
top <- students[students$score >= 90, ]
print(top)

# Summary of the whole frame
summary(students$score)

> source("dataframe.R")

   name score grade
1 Alice    92     A
2   Bob    78     C
3 Carol    95     A
4  Dave    85     B
[1] "Alice" "Bob" "Carol" "Dave"
   name score grade
1 Alice    92     A
3 Carol    95     A
   Min. 1st Qu. Median  Mean 3rd Qu.  Max.
  78.00   82.25   88.50 87.50   92.75  95.00
functions.R
R
# Define a function
bmi <- function(weight, height) {
  round(weight / height^2, 1)
}

print(bmi(70, 1.75))    # single call
print(bmi(90, 1.80))

# Apply a function to a vector
weights <- c(60, 75, 90, 55, 80)
heights <- c(1.65, 1.75, 1.80, 1.60, 1.70)

# mapply β€” apply over multiple vectors
bmis <- mapply(bmi, weights, heights)
print(round(bmis, 1))

# sapply β€” apply to a list, return vector
nums <- list(a = 1:5, b = 6:10, c = 11:15)
means <- sapply(nums, mean)
print(means)

> source("functions.R")

[1] 22.9
[1] 27.8
[1] 22.0 24.5 27.8 21.5 27.7
   a    b    c
 3.0  8.0 13.0
Data science
πŸ”¬ Data Science & AI

Explore the Data Science category

R is the statistician's first choice. Also explore Python for machine learning, SQL for database queries, and Julia for high-performance numerical computing.

Frequently Asked Questions

What is R?

R is a free, open-source programming language and environment for statistical computing and graphics. Created in the early 1990s by Ross Ihaka and Robert Gentleman at the University of Auckland, it is the standard tool in academia, biostatistics, data science and quantitative research worldwide.

Who uses R?

Data scientists, statisticians, researchers, bioinformaticians, financial analysts, and economists. Companies like Google, Facebook, Twitter, Microsoft, and the New York Times use R for data analysis and visualisation. It is also the dominant language in academic research across medicine, social science, and ecology.

R vs Python for data science β€” which should I learn?

Both are excellent. Python is more general-purpose and popular in machine learning engineering and production systems. R has a deeper statistical foundation, better built-in tools for traditional statistics, and ggplot2 produces the most beautiful publication-ready charts of any tool. Many data scientists know both. If your work is statistical analysis or academic research, start with R. For ML engineering, start with Python.

Is R hard to learn?

The basics β€” vectors, data frames, and built-in functions β€” are straightforward. R can feel unusual if you come from another language because it is vector-first: operations work on whole vectors without explicit loops. Once that clicks, R becomes very powerful and concise. The tidyverse collection of packages (dplyr, ggplot2, tidyr) makes modern R elegant and readable.

What is ggplot2?

ggplot2 is R's most popular data visualisation package, created by Hadley Wickham. It implements the "Grammar of Graphics" β€” a principled way to describe any chart as layers of data, aesthetics, and geometric objects. ggplot2 produces publication-quality graphs with far less code than most other plotting tools.

Ready to analyse data?

Free. No signup. No downloads. Just start.

Start Learning R

No account required Β· Always free

The Story of R

Real history, real companies, and an honest look at where Rshines and where it doesn't β€” not just a feature list.

πŸ•°οΈ

Where it came from

R was created in 1993 by statisticians Ross Ihaka and Robert Gentleman at the University of Auckland, built as a free, open-source alternative to the expensive commercial statistical software (like SAS and S-PLUS) that dominated academic research at the time. Its design still shows this statistics-first origin β€” R treats things like data frames and statistical models as core language features, not add-on libraries.

🏒

How it’s actually used today

R remains the default tool in academic biostatistics and epidemiology β€” it was heavily used in COVID-19 modelling by public health agencies worldwide β€” and pharmaceutical companies rely on it for clinical trial analysis, partly because regulatory bodies are familiar with its statistical output conventions. The ggplot2 package in particular is considered one of the best data visualisation tools in any language.

βš–οΈ

Strengths & trade-offs

R's deep, built-in statistical capabilities make it genuinely faster than Python for certain specialist analyses β€” particularly in fields like genomics and clinical research where R packages are the established, peer-reviewed standard. Its trade-off is a smaller general-purpose ecosystem outside statistics; you wouldn't build a web application or mobile app in R.

🧭

What to learn next

Because R and Python-for-data-science solve overlapping problems, many analysts eventually learn both and use whichever has better tooling for a specific task. SQL is essential either way, since real-world data for R analysis usually starts life in a database.