An introduction to programming in R -- Part 1



Use the left and right arrow keys to navigate the presentation forward and backward respectively. You can also use the arrows at the bottom right of the screen to navigate with a mouse.

This site is for educational purposes only. This website may contain copyrighted material, the use of which has not been specifically authorized by the copyright holders. The material is made available on this website as a way to advance teaching, and copyright-protected materials are used to the extent necessary to make this class function in a distance learning environment. The Fair Use Copyright Disclaimer is under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research.


  • The following topics will be covered in this lecture:

    • What is R and RStudio
    • How to install packages and get help
    • How to use R as a calculator
    • Variables and data types


  • This course will lean heavily on programming;

    • while it is possible to perform statistical analysis by hand for some very simple problems, any realistic problem solving must be done on a computer.
  • This course does not assume that you are already familiar with programming;

    • this course will also not require a deep knowledge of programming or computer science.
    • However, everyone is responsible to learn enough R to become proficient with standard modeling and plotting functions.
  • Students are recommended to use the lessons in Sofware Carpentry as a free reference for scientific programming in R.

What is R?

  • There are a number of common choices of programming/ scripting languages for performing statistical modelling, e.g.:
    • SAS
    • SPSS
    • STATA
    • Python
    • R
  • We will use R for the following reasons:
    1. it is free and open source software with extensive documentation and tutorials available;
    2. it has well established libraries for statistical modeling with a wide functionality;
    3. the “Faraway” package has extensive educational examples available for running our analyses;
    4. there are free interactive, introductory lessons from DataCamp which will be used for the first homework.