Chapter 2: Control Structures

Understand how control structures dictate the flow of execution of a sequence of operations.

1General information

2A simple example of control structures

3Logical operators

4If/else and switch statements

5Iterative control statements

6Logical operators, if/else statement and iterative control statements: Exercises

About the course, the professor and the TAs

This course is intended to provide an introduction to data science using the R language. It will also provide students with notions of data management and manipulation, data analytics as well as of reproducible research, result-sharing and version control (using GitHub). At the end of the class, students should be able to automatically extract data from websites and create interactive web apps as well as dynamic reports to visualize and analyze them. Students should also be able to construct their own R packages, make them available on GitHub and document them using literate programming.

The material presented in this website was mainly developed by Stéphane Guerrier, Lionel Voirol and Yuming Zhang. Moreover, we thank Luca Insolia for his valuable contributions. Stéphane Guerrier is an Assistant Professor of Statistics and Data Science at the University of Geneva. Yuming Zhang and Lionel Voirol are PhD Candidates in Statistics at the University of Geneva. Luca Insolia is a postdoctoral researcher in Statistics at the University of Geneva.