R is the lingua franca of academic statistics, a major language in applied research and policy work, and the home of two ecosystems that no other language matches: the tidyverse for data manipulation and ggplot2 for graphics. If you do econometric research, R will be the tool you reach for at least half the time.
Vector-first by default
R was designed for statistics from the ground up. Its primary data type is the vector, not the scalar. Operations work element-wise without ceremony. This makes R unusually concise for the kinds of computations a statistician does — and unusually quirky for programmers coming from other languages.
x <- c(1, 2, 3, 4, 5)x * 2 # 2 4 6 8 10mean(x) # 3x > 3 # FALSE FALSE FALSE TRUE TRUE
The assignment arrow
R uses <- (an arrow) for assignment, with = also accepted but considered less idiomatic. The arrow makes it visually obvious which way data is flowing. RStudio (the IDE most R users use) has a keyboard shortcut: Alt+- inserts <- with surrounding spaces.
Reading the help pages
Type ?function_name in the R console to open the help page. Every function in R has a structured help page with: arguments, value, examples, references. The examples at the bottom are usually the fastest way to figure out what a function does.
?mean?lmhelp("summary")
WebR — running R in your browser
The practice environment to the right of this course runs real R compiled to WebAssembly via WebR. The tidyverse and ggplot2 are pre-loaded. Three Kenyan datasets — bankrates, pension, mpesa — are loaded as data frames so you can practise on real data immediately.
R is unusual but consistent
Coming from Python, R will feel weird for a week. The vector-first nature, the <- arrow, the formula notation y ~ x, the [[]] vs [] distinction — they are all consistent with R's design but not with general programming language conventions. Embrace it; the conciseness is real.
Exercise
Print the string 'Hello, Kenya' (exact text, including the comma).