</>
Skip to content
R lessons (2/41)

R — Introduction

What is R?

R is a programming language built for statistics and data analysis. Where Python is general-purpose, R was designed from the ground up for working with data — exploring datasets, building statistical models, and creating publication-quality visualizations.

Created in 1993 by Ross Ihaka and Robert Gentleman at the University of Auckland, R is based on the S language from Bell Labs. It's freely available and runs on every major operating system.

Who uses R?

  • Statisticians and researchers — the original and still primary audience
  • Data scientists — for exploratory data analysis and visualization
  • Bioinformatics — R dominates computational biology (Bioconductor)
  • Finance — quantitative analysis and risk modeling
  • Epidemiology — disease modeling and public health research
  • Machine learning — caret, tidymodels, and hundreds of ML packages

R is the language of choice in academia and research. If you read a scientific paper with custom analysis, chances are R was used.

What R looks like

# Load data
data <- mtcars

# Calculate average miles per gallon
avg_mpg <- mean(data$mpg)
cat("Average MPG:", avg_mpg, "\n")

# Create a simple plot
plot(data$wt, data$mpg,
     main = "Weight vs MPG",
     xlab = "Weight (1000 lbs)",
     ylab = "Miles per Gallon")

R has a distinctive syntax — the <- assignment operator, the $ for accessing columns, and built-in plotting that creates charts with one line.

Why learn R?

  1. Data analysis first-class — R's core design revolves around data
  2. Visualization — ggplot2 is the gold standard for statistical graphics
  3. Packages — CRAN hosts 20,000+ packages for every statistical method
  4. Community — passionate, helpful, and academically oriented
  5. Reproducibility — R Markdown and Quarto make reproducible research easy

R vs Python for data science

FeatureRPython
Primary useStatistics, visualizationGeneral purpose + data
Learning curveSteeper for non-statisticiansGentler for programmers
Visualizationggplot2 (excellent)matplotlib, seaborn (good)
StatisticsDeeper, more specializedGood, but less complete
Machine learningcaret, tidymodelsscikit-learn (larger)
CommunityAcademic, researchIndustry, production

Many data scientists learn both. R for exploration and visualization; Python for production and deployment.

The tidyverse ecosystem

Modern R development centers on the tidyverse — a collection of packages with a consistent design philosophy:

  • dplyr — data manipulation (filter, select, mutate, summarize)
  • ggplot2 — visualization based on the grammar of graphics
  • tidyr — tidying messy data
  • readr — fast data import
  • purrr — functional programming
  • stringr — string manipulation
  • forcats — factor handling
library(dplyr)

mtcars %>%
  filter(cyl == 6) %>%
  select(model = rownames(.), mpg, hp) %>%
  arrange(desc(mpg))

The pipe operator %>% chains operations together, making code read left to right.

RStudio — the standard IDE

RStudio (now Posit) is the most popular R environment:

  • Syntax highlighting and autocomplete
  • Integrated plotting and viewer
  • Variable explorer
  • Package management
  • R Markdown support
  • Git integration

Download from posit.co — it's free and open source.

What you'll learn

  1. R syntax and data types
  2. Vectors, lists, and data frames
  3. Data manipulation with dplyr
  4. Visualization with ggplot2
  5. Statistical analysis fundamentals
  6. Working with real datasets
  7. Building reports with R Markdown

R has a reputation for being quirky. Embrace the quirks — they exist because R was designed by statisticians who cared about making data analysis natural and expressive.

Next: setting up R and RStudio →

Related Topics

Frequently Asked Questions about Introduction

What is Introduction in R?

Introduction is a fundamental concept in R. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Introduction?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Introduction.

Why is Introduction important in R?

Introduction is essential for R development. Understanding this concept will help you write better code and solve real-world problems more effectively.