Lesson 1 / 25
What R Is For
Describe R's strengths, its ecosystem and when to choose it.
A language built for data
R is a free, open-source language and environment for statistical computing and graphics, descended from the S language developed at Bell Labs. It is widely used in statistics, data analysis, bioinformatics, epidemiology, economics, finance and academic research, and in industry teams doing analytics and reporting. R's strengths: thousands of statistical methods implemented by statisticians themselves, excellent data visualisation (especially with ggplot2), the tidyverse collection of packages for consistent data manipulation, and first-class tools for reproducible reports (R Markdown and Quarto) and interactive dashboards (Shiny). More than 20,000 packages are available on CRAN (the Comprehensive R Archive Network), plus many more on Bioconductor for genomics. R is vectorised: most operations work on whole vectors at once, and it is usually used interactively in a console or notebook-style editor. Compared with Python, R is often preferred for classical statistics and publication-quality graphics, while Python dominates general software engineering and deep learning; many data scientists use both.
From raw data to insight
A typical R workflow: import, tidy, transform, visualise, model and communicate.
A first look at R
Vectors, summary statistics and a quick plot in a few lines.
marks <- c(72, 45, 90, 38, 66, 81) # a numeric vector
mean(marks) # average
summary(marks) # min, quartiles, median, mean, max
sum(marks >= 40) # how many passed (TRUE counts as 1)
passed <- marks[marks >= 40] # keep only passing marks
round(sd(passed), 1) # standard deviation
hist(marks, main = "Distribution of marks", xlab = "Marks") # base R plotThink in vectors, not loops
Newcomers from C or Java write loops for everything. In R, marks >= 40 compares every element at once. Vectorised code is shorter, clearer and usually much faster.
Quick check: For which kind of work is R especially well known?
- Statistical analysis and data visualisation
- Operating system kernels
- Mobile game engines
- Device drivers
Answer
Statistical analysis and data visualisation — R was designed for statistics and graphics and excels at them.