In the Metropolitan Data I course at Amsterdam Institute for Advanced Metropolitan Solutions, the students were familiarised with techniques for acquiring, processing, analyzing, and representing a range of data including mobility data, geographical data, social data and consumption data.
For this course, five R tutorials were designed, and all the materials and resources are available.
Course coordinator: Dr. Julián Urbano
Teaching assistants: Harlley Lima and Manel Slokom
Most of the R tutorials of this course are based on R for Data Science by Hadley Wickham & Garrett Grolemund. This book covers data manipulation, visualization, and transformation - topics also covered in our tutorials. The first two tutorials presented here are based on the Foundations chapter of Advanced R by Hadley Wickham.
RStudio is an IDE which provided tools designed to enhance the productivity with R, we strongly recommended this development environment for the course. RStudio includes an editor (syntax highlighting, code completion, and smart indentation) from which the code can be easily executed, as well as a console and tools for debugging, plotting, and history. RStudio is integrated with R help and documentation, making easy to solve most of the questions that you may have.
Open-source and commercial RStudio editions can be downloaded here (available for Windows, Mac, and Linux).
You also need to install R. If you choose to install RStudio, then you don’t need to worry about R installation since it is already installed with RStudio. Otherwise, you need to install R, coding with an editor more convenient for you, and then run your code from the command line. Please, use RStudio to have a nice R experience :)
For each tutorial is available the presentation pdf, pdf latex files (if want to improve the presentation go for it, and let me know :) ), and R file with the code used during the tutorial.
This tutorial covers:
- Coding basics: console, expression, operators, variables, relational operators, logical operators, basic data types
- Built-in Functions
- Data types: vectors, factors, matrices and arrays, list and data frames
[pdf], [latex files], [script]
This tutorial covers:
- R Script and RStudio: code completion, exectuing code, keyboard shortcuts
- Control structures:
- Conditional exectuion: if and if-else statements
- Repetitive exectuion: for loops, repeat and while
- User-defined functions: summary measures functions, defining a function, argument matching, the … argument
- Loop functions: lapply(), sapply(), apply()
[pdf], [latex files], [script]
This tutorial covers:
- Packages
- Tibbles
- Data import
- Tidy data: spreading, gathering, separating, uniting and missing values
- Relational data: keys and mutating joins
[pdf], [latex files], [script]
This tutorial covers:
- ggplot2: aesthetic mappings, facets, geometric objects, position adjustments
- Exploratory data analysis: variation and covariation
[pdf], [latex files], [script]
This tutorial covers:
- Primary functions: select(), select(), group_by(), summarise(), arrange(), mutate(), mutate()
- RStudio project: RStudio project creation and working directory
[pdf], [latex files], [script]