Unit 2

Introduction

Welcome to Week 2 of BIO144!

Course book

This week we will be covering Chapter 2: R and RStudio of the course book.

Code walkthrough

The R code of this week’s chapter is in a code walkthrough script, with a video walkthrough of it. Both are linked at the top of the course book chapter. Work through them before the practical: the last section of the script (“Practical toolbox”) shows code that this week’s practical uses but the chapter does not.

Learning objectives

These learning objectives, together with the content of the course book chapter, define what you need to know for the exam.

After this unit, students will be able to:

  1. Explain the purpose of the script, the console and the environment in RStudio.
  2. Write and run R code in a script, using objects, functions and arguments correctly.
  3. Install and load add-on packages, and explain the difference between installing and loading a package.
  4. Use R’s help system and other resources to find out how a function works and what arguments it takes.
  5. Import a dataset into R and inspect its structure, including the variable names and variable types.
  6. Convert variables to factors, and set or change the reference level of a categorical variable.
  7. Manipulate data in R: select variables, filter observations, create new variables, and calculate summaries by group.
  8. Produce exploratory graphs (e.g. histograms, scatterplots, box plots) to inspect distributions of and relationships between variables.
  9. Identify and fix common errors in R code (e.g. typos, misspelled variable names, packages not loaded).
  10. Organise an analysis as a script within an RStudio project, with meaningful names for datasets and model objects, that reproduces all results when run from top to bottom.

Lecture

Please attend the lecture. If for any reason you can’t, please watch the podcast, which is available on OLAT.

Homework, Practical, and Weekly Quiz

Available here. You will need to be on a UZH network to access this link, so if you are not on campus, you will need to connect to the UZH VPN first.