Helsingin yliopisto Department of Mathematics and Statistics
Faculty of Science
Faculty of Social Sciences


Software Tools, Part 1: introduction to R software

R links

  • R project homepage.
  • CRAN (the Comprehensive R Archive Network) for downloading versions of R for Windows, Mac and Linux computers.

Online material on R for the Software Tools course

  • Getting to know R: how to use R in room C128; general instructions on using R; how to install R on your own computer.

The material consists of web pages and files containing R code. You should download the R code files and put them in a suitable directory. Then you are supposed to run the code a few lines at time, and inspect the results.

(There is more material here than what will be covered during the course.)

  • R code: Using R as a calculator. Variables and assignment statements. (31 Jan)
  • R code: Function calls; getting help. (31 Jan)
  • R code: Vectors and indexing. (31 Jan and 3 Feb)
  • R code: Lists. (3 Feb)
  • R code: Matrices and arrays. (3 Feb)
  • R code: Factors. (3 Feb)
  • R code: Data frames. (3 Feb and 7 Feb)
  • R code: Data input. Copy also the files e1.dat, e2.dat and e3.dat. (7 Feb)
  • R code: Function apply() and related functions. (7 Feb)
  • R code: Writing your own functions. (7 Feb and 10 Feb)
  • R code: Conditional execution. (10 Feb)
  • R code: Loops. (10 Feb)
  • R code: Functions source(), sink(), save() and load(). (10 Feb)
  • R code: Classes and methods. (10 Feb)
  • R code: Dates. (Skipped at lectures)
  • R code: Introduction to R graphics. (10 Feb)
  • R code: Saving graphics to a file. (14 Feb)
  • Traditional R graphics
    • R code: Function plot(). (14 Feb)
    • R code: Arguments to plot(). (14 Feb)
    • R code: Interaction with plots. (Skipped)
    • R code: Adding material to plots. (17 Feb)
    • R code: Other high-level functions in traditional graphics. (17 Feb)
  • R code: Lattice graphics. (Skipped)
  • R code: Probability distributions and their simulation. (Began on 17 Feb)
  • R code: Summary statistics. (Skip)
  • R code: Traditional tests and confidence intervals.
  • R code: Simple linear regression. File e1.dat.
  • R code: Linear regression when the predictors are numeric. File cement.dat.
  • R code: Factors in linear models. Files bilirubin.dat and uffi.dat.


There will be four sets of exercises with 5 or 6 problems in a set. You will get the credits for the first part of the course by sending a sufficient number of solutions to the problems by email. In order to get the credits, send solutions to

  • at least half of the total number of problems and
  • at least two problems from each of the four sets.

(but if you give me a good reason, I may make an exception to these rules).

The lecturer's solutions will be discussed during the lectures.

  • Set 1 - due to 7 Feb, 2011. Suggested solutions: r1sol.html.
  • Set 2 - due to 14 Feb, 2011. Suggested solutions: r2sol.html.
  • Set 3 - due to 21 Feb, 2011. Suggested solutions: r3sol.html.
  • Set 4 - due to 3 March (notice that deadline is on Thursday). The solutions will be discussed on 3 March. Suggested solutions: r4sol.html.

Here are your points.

Online documentation for R

  • The R program comes with its manuals, which you can read through the help menu of Rgui. They are also available on the page The R Manuals of CRAN. See especially the manual An Introduction to R.
  • In addition to the official documentation, CRAN contains a lot of contributed documentation, which you can find on the page Contributed Documentation. For instance, the documents written by Maindonald, Verzani, Faraway, and Paradis are very useful.
  • You should print one of the following reference cards for yourself.
  • Seasoned users of Octave or Matlab should take a look at
  • The 'official' R Wiki (at R project homepage -> Wiki)
  • Rtips: tips and tricks collected by Paul Johnson.

Suomenkielistä materiaalia R:n käytön tueksi

Books on R

See R project -> Books for a comprehensive list of books. I have seen and can recommend the following books.

  • P. Dalgaard. Introductory Statistics with R, 2nd ed., Springer, 2008.

    A compact book which shows the beginner how to use R for typical statistical analyses.

  • J. Maindonald and J. Braun. Data Analysis and Graphics Using R: An Example-based Approach, Cambridge University Press, 2003.

    Another book which shows the beginner how to use R for making statistical analyses. Slightly more advanced and lot bulkier than the book by Dalgaard.

  • J. Adler. R in a Nutshell: A Desktop Quick Reference, O'Reilly, 2009.

    A refence book which also suits the needs of a beginner.

  • W. J. Braun and D. J. Murdoch. A First Course in Statistical Programming with R, Cambridge University Press, 2007.

    A compact book which introduces R and statistical programming in general.

  • W. N. Venables and B. D. Ripley. Modern Applied Statistics with S. Fourth Edition. Springer, 2002.

    How to make a host of modern statistical analyses with S or R. The library MASS is connected with it.

  • B. S. Everitt and T. Hothorn, A Handbook of Statistical Analyses Using R, 2nd ed., CRC Press, 2010.

    How to analyze various statistical models with R.

  • M. Aitkin and B. Francis and J. Hinde and R. Darnell, Statistical Modelling in R, Oxford University Press, 2009.

    How to analyze various statistical models with R.

  • P. Murrell. R Graphics. Chapman & Hall/CRC, 2005.

    The best description of the graphics facilities of R.

  • D. Sarkar. Lattice: Multivariate Data Visualization with R. Springer, 2008.

    The best available resource on lattice graphics.

  • W. N. Venables and B. D. Ripley. S Programming. Springer, 2000.

    A thorough exposition of programming in the S or R language for people who already know how to use the system.

  • U. Ligges. Programmieren mit R. 3rd edition, Springer, 2008.

    A compact exposition of programming in the R language for people who are not afraid to read German.

Last updated 2011-03-03 10:06
Petri Koistinen
petri.koistinen 'at' helsinki.fi