ETC53250/5250 Tutorial 1

Getting set up

Author

Prof. Di Cook

Published

26 February 2024

🎯 Objectives

The goal for this week is for you to get up and running with the computing environment needed to successfully complete this unit.

🔧 Preparation

  • Install the latest versions of R and RStudio on your computer
install.packages(c("tidyverse", "tidymodels", "tourr", "geozoo", "mulgar", "ggpcp", "plotly", "detourr", "langevitour", "ggbeeswarm", "MASS", "GGally", "ISLR", "mvtnorm", "rpart", "rpart.plot", "randomForest", "e1071", "xgboost", "Rtsne", "classifly", "penalizedLDA", "nnet", "kernelshap", "shapviz", "iml", "DALEX", "cxhull", "fpc", "mclust", "ggdendro", "kohonen", "aweSOM", "patchwork", "ggthemes", "colorspace", "palmerpenguins"), dependencies = TRUE)
  • Create a project for this unit called iml.Rproj. All of your tutorial work and assignments should be completed in this workspace.

Exercises:

1. The materials at https://learnr.numbat.space are an especially good way to check your R skills are ready for the unit. Regardless how advanced you are, at some point you will need help. How you ask for help is a big factor in getting your problem fixed. The following code generates an error.

library(dplyr)
library(MASS)
library(palmerpenguins)
p_sub <- penguins |>
  select(species, flipper_length_mm) |>
  filter(species == "Adelie")
  1. Can you work out why?
  2. Use the reprex package to create a text where the code and error are visible, and can be shared with someone that might be able to help.

The error is

Error in select(penguins, species, flipper_length_mm) : 
  unused arguments (species, flipper_length_mm)

and is caused by a conflict in functions between the dplyr and MASS packages. If you read the warning messages when the packages were loaded you might have been aware of this before trying to run code.

You can fix it by:

  1. Prefacing functions that have conflicts with their package name, eg dplyr::select()
  2. Use the conflicted package to set your preferences at the start of any document.

To make the reprex, copy the code to clipboard, and run reprex(). This will generate:

2. Your turn to write some code that generates an error. Create a reprex, and share with your tutor or neighbour, to see if they can fix the error.

3. Follow the guidelines at https://tensorflow.rstudio.com/install/ to setup python and tensorflow on your computer. Then test your installation by following the beginner tutorial.

4. Download the slides.qmd file for week 1 lecture.

  1. Use knitr::purl() to extract the R code for the class.
  2. Open the resulting slides.R file in your RStudio file browser. What code is in the setup.R file that is sourced at the top?
  • Libraries are loaded.
  • There are some global options for slides set, and styling of plots.
  • Conflicts for some common functions are resolved with preferences.
  1. Run the rest of the code in small chunks. Does it all work for you? Do you get any errors? Do you have any suggestions on making it easier to run or understand the code?

👋 Finishing up

Make sure you say thanks and good-bye to your tutor. This is a time to also report what you enjoyed and what you found difficult.