“Introduction to Programming with R is a learning resource for programming novices who want to learn programming using the statistical programming language R. While one of the major strengths of R is the broad variety of packages for statistics and data science, this resource focuses on learning and understanding basic programming concepts using base R. Only a couple of additional packages are used and/or briefly discussed for special tasks.

This online book is specifically written for participants of the course “Introduction to Programming: Programming in R” offered by the Digital Science Center at Universität Innsbruck. If you are interested in further literature you may consider other resources:

A big thank you

… goes to all who helped writing and improving this book. Whether it was a full chapter, a section, or drawing attention to errors, typos, or incomprehensible wording.

As for now, this learning ressource has to be seen as ‘work in progress’ and there are, for sure, many more typos and transposed letters which will be fixed in the (near) future.

Practical exercises

Every now and then you will find “practical exercises” within the chapters indicated by an orange question mark. By clicking on the title the exercise will show up (open). The exercises come with solutions (indicated by an orange light bulb). By default, the solution is hidden (closed). Try to solve the exercise on your own before reading the solution!

A hand is an old non-SI unit to measure the size of a horse. An Australien friend just called us and told us he bought a new horse “[…] which is 12.5 hands tall.”. One hand is 101.6 millimeters. How tall is his horse in meters?

Well, that’s a very simple question, but the solution would be something like:

## [1] 1.27
## His horse is  1.27 meters tall

Advanced topics

Advanced blocks contain content which goes beyond the “main topic” of this course. Feel free to skip these parts if you think they may be too difficult for you at the moment.

Sometimes you will find blocks which look like this one. These blocks indicate advanced topics (or the beginning of a section labeled as “advanced”).


Occasionally you will find “excursion” entries. They are not mandatory but show additional hints/examples.

Not real exercises, nor advanced topics, just small excursions from the current topic or additional hints/details about specific functions or methods.