## `r emo::ji("target")` Objectives

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

## `r emo::ji("wrench")` Preparation 

- Install the latest versions of [R](https://cran.rstudio.com) and [RStudio](https://posit.co/downloads/) on your computer

```{r}
#| eval: false
#| code-fold: false
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](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. 

```{r}
#| eval: false
library(dplyr)
library(MASS)
library(palmerpenguins)
p_sub <- penguins |>
  select(species, flipper_length_mm) |>
  filter(species == "Adelie")
```
a. Can you work out why?
b. 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.

::: unilur-solution

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:

![](images/reprex.png)

:::

#### 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](https://tensorflow.rstudio.com/tutorials/quickstart/beginner).

#### 4. [Download](https://github.com/numbats/iml/blob/master/week1/slides.qmd) the `slides.qmd` file for week 1 lecture. 

a. Use `knitr::purl()` to extract the R code for the class. 
b. 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?

::: unilur-solution
- Libraries are loaded.
- There are some global options for slides set, and styling of plots.
- Conflicts for some common functions are resolved with preferences.
:::

c. 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?

## `r emo::ji("wave")` 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.
