© 2026 Dometrain. All rights reserved.
Learn R by writing small functions in your browser, from vectors, indexing and NA to strings, lists, the apply family and data frames.
R looks familiar until the first result surprises you. A single number is a vector of length one and arithmetic works on whole vectors, so x * 2 doubles every number in x without a loop, and a shorter vector quietly repeats to match a longer one. Positions start at 1, and x[-1] means “everything except the first element”, not the last one. A missing value is NA and carries through every sum that touches it, 1:length(x) counts down to 0 when x is empty, and a list needs [[ where you expected [. If you already write C#, Java, JavaScript, Python or Go, you usually know what you want the code to do and need to see how R expects it to be written.
R for Beginners is a hands-on course of 25 exercises that run in your browser. Each lesson explains one part of the language with a short example, then asks you to write a function; your code is called with several inputs, and each result is compared with the expected one. You start with functions, vectors, vectorized arithmetic and recycling, sequences and indexing by position, then logical indexing, named vectors, NA and sorting with order(). Next comes control flow: if and else, ifelse(), for loops over seq_along(), while, switch() and tryCatch(). A chapter on strings covers paste(), sprintf(), substr() and patterns with grepl() and gsub(). The later chapters cover lists and the apply family (vapply(), Filter(), Reduce()) and closures, and finish with factors and data frames: filtering rows, aggregate() and tapply(), and a final exercise that turns groups and scores into a per-group report, returned as a data frame.
The course suits programmers who are new to R and comfortable with variables, loops and functions in another language. Nothing needs to be installed, and every exercise uses base R alone, with no extra packages.