The R Primer provides a collection of concise examples with solutions and interpretations of R problems frequently encountered by new users of this statistical software. The R Primer contains numerous examples that illustrate a specific situation, topic, or problem, including data importing, data management, classical statistical analyses, and high-quality graphical production. Each example is self-contained and includes R code that can be run exactly as shown, enabling results from the book to be replicated.

New to the Second Edition:

The site contains source code, extra material and errata.


“This book provides a good introduction to R, using a clear layout and detailed, reproducible examples. An ideal tool for any new R user. … A wide range of topics are covered, making the book suitable for a variety of readers, from undergraduate students to professionals new to R … an extremely helpful introduction to a very useful statistical package.”

  • Claire Keeble, Journal of Applied Statistics, 2012

Table of contents

About the author

Claus Thorn Ekstrøm is Professor at the Section of Biostatistics, University of Copenhagen where he teaches courses on statistics and R for beginners and advanced users. Professor Ekstrøm’s primary research interests lie within statistical genetics, genetic epidemiology, and bioinformatics, in particular genetic association studies, image analysis of microarray scans, and integrated analysis of gene expression and metabolic profile data.

Differences between the 1st and 2nd editions

The 2nd edition has updated the existing solutions to reflect new packages and improvements in R and an extra 33% material has been added.

Created by Claus Ekstrøm 2017, page last updated 24 October, 2020