Hide menu

732G33 Programming in R

Course information

This is the web site for the course in programming using the statistically oriented programming language R given by Statistics at Linköping University. The course is given every spring semester. The following material was used when the course was taught in Spring 2012.
Getting started with R at home

  1. Download R
  2. Download RStudio
  3. Read An Introduction to R
  4. Start playing around with R.

The aim of the course is to introduce basic programming ideas and techniques, with special emphasis on the statistical programming language R.
Intended audience

This course is given mainly for students on the first year of the Bachelor's programme Statistik och Dataanalys. It will be taught in Swedish in 2012. I am writing this in English since students on the international Master's programme Statistics and Data Mining may find some other material here useful in their study course on R programming.

The course is organized into 5 modules. Each module includes a:
  • Föreläsning, F (Lecture ). The lecture introduces new concepts and sets the stage for the computer lab.
  • Datorlabb, D (Computer lab). This is the most important part of the course where you practice programming by solving problems in pairs.
  • Uppföljning, U (Follow-up meeting). The follow-up meeting is used to discuss problems that you encountered in the lab, alternative ways of solving the lab, and extensions flowing from material in the lab.
Course management

I use the course management system CourseKit for the course. Go to coursekit.com and register using the course code that I will hand out during the first lecture.

  • R Cookbook, by Paul Teetor.
  • My Slides.
  • Fotocopies of Section 4.1 (loops/If else conditions) and 4.5 (debugging) in the book 'A First Course in Statistical Programming with R' by Braun and Murdoch
  • The Art of R Programming by Norman Matloff. This book is not required reading, it is only recommended for more depth.

F = Föreläsning (Lecture), D = Datorlabb (Computer lab), U = Uppföljning (Follow-up) meeting
What? Date? Time? Where? R Cookbook Slides/Handouts
Module 1. Introduction to computers, programming and R
F1 January, 30 13-15 A33 1.1-1.7, 1.10, 2.1-2.5, 3.1-3.4, 4.1, 4.4-4.5, 4.7-4.8, 4.10, 4.14. Lecture1 1 slide/page
Lecture1 4 slides/page
D1 January, 31 08-10 SU10-11 SU15-18 Lab1
U1 February, 7 10-12 Visionen U1 1 slide/page U1 4 slides/page
Module 2. Data structures, functions and objects
F2 February, 13 13-15 Visionen 2.6-2.10, 2.12, 5.1-5.4, 5.6-5.8, 5.18, 5.20, 5.22-5.26, 5.31. Lecture2 1 slide/page
Lecture2 4 slides/page
D2 February, 16 10-12 SU10-11 SU15-18 Lab2
U2 February, 24 10-12 TEMCAS
Module 3. Basic programming techniques, debugging and coding style
F3 February, 27 13-15 A32 Copied pages on loop etc Style guidelines 6.2, 6.5, 12.16. Lecture3 1 slide/page
Lecture3 4 slides/page
D3 February, 28 08-10 SU10-11 SU15-18 Lab3
U3 March, 7 13-15 Visionen
Module 4. Statistics and graphics in R
F4 March, 8 10-12 Visionen 8.3, 8.5, 8.8-8.11, 9.1, 9.7-9.9, 10.1-10.2, 10.5, 10.9, 10.12-10.15, 10.18-10.19, 10.26-10.29, 11.1-11.3, 11.7-11.8, 11.11. Lecture4 1 slide/page
Lecture4 4 slides/page
D4 March, 12 10-12 SU10-11 SU15-18 Lab4
U4 March, 16 13-15 Visionen
Module 5. R packages, matrix computations, strings, time series.
F5 March, 19 10-12 TEMCAS 1.9, 1.11, 3.6, 3.8-3.9, 5.14-5.15, 13.3, 12.4, 12.7, 12.11-12.12, 7.1-7.3, 7.9, 7.11, 14.1-14.2, 12.6. Lecture5 1 slide/page
Lecture5 4 slides/page
D5 March, 20 10-12 SU10-11 SU15-18 Lab5
U5 March, 27 10-12 TEMCAS
Exam March, 30 08-12 SU10-11 SU15-18

Extra material


  • The code snippet presenting during lectures can be accessed by visiting the page¬†http://dl.dropbox.com/u/4522672/R2012/Code/OneOfMyFunctions.R, where you replace OneOfMyFunctions with the name of the particular function you are interested in (you need to know the name of the function, see my slides). You can also download a zip-file with all the code snippets here.

Page responsible: Mattias Villani
Last updated: 2012-09-12