Skip to content

Commit

Permalink
1806 ch4 ex
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanrongen committed Jun 18, 2024
1 parent 88b9da0 commit ddd015f
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 185 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions _freeze/materials/data-wrangling/execute-results/html.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file modified materials/.DS_Store
Binary file not shown.
6 changes: 5 additions & 1 deletion materials/_no-render/template.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ exec(open('setup-files/setup.py').read())
Description

::: {.callout-answer collapse=true}
## Answer

::: {.panel-tabset group="language"}
## R
:::
:::
:::

:::{.callout-important}
Complete [Exercise -@sec-exr_title].
:::


## Key points

::: {.callout-note}
Expand Down
1 change: 1 addition & 0 deletions materials/data-wrangling.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ This gives us a 'wide' table, where the original data are split by the type of `
Deciding which format to use can sometimes feel a bit tricky. Relating it to plotting can be helpful. Ask yourself the question: "what is going on the x and y axis?". Each variable that you want to plot on either the x or y axis needs to be in its own column.

:::

## Exporting data

It can be useful to save data sets you create throughout your analysis.
Expand Down
Binary file added materials/data/.DS_Store
Binary file not shown.
360 changes: 180 additions & 180 deletions materials/data/finches.csv

Large diffs are not rendered by default.

121 changes: 121 additions & 0 deletions materials/intro-to-programming.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ because it will fail on someone else's computer.

:::

:::{.callout-important}
Complete [Exercise -@sec-exr_project].
:::

## Writing code

::: {.panel-tabset group="language"}
Expand All @@ -163,6 +167,10 @@ command you can hit <kbd>Esc</kbd> and RStudio will give you back the `>` prompt

:::

:::{.callout-important}
Complete [Exercise -@sec-exr_calculations].
:::

## Creating scripts

::: {.panel-tabset group="language"}
Expand All @@ -184,6 +192,10 @@ by pressing the shortcut <kbd>Ctrl</kbd>+<kbd>Enter</kbd>.

:::

:::{.callout-important}
Complete [Exercise -@sec-exr_scripts].
:::

## Installing and loading packages

::: {.panel-tabset group="language"}
Expand Down Expand Up @@ -213,6 +225,115 @@ library(tidyverse)

:::

:::{.callout-important}
Complete [Exercise -@sec-exr_packages].
:::

:::{.callout-important}
Remember, we only need to **install** a library/package *once*. However, we need to **load** it every time we start an analysis.
:::



## Exercises

### Setting up a project {#sec-exr_project}

:::{.callout-exercise}

{{< level 1 >}}

Set up a project and make sure it's set as your working directory.

:::

### Calculations {#sec-exr_calculations}

:::{.callout-exercise}

{{< level 1 >}}

Run the following calculations:

* `2 + 23`
* `23 * 4`
* `314 - 82`
* `(12 - 4) * (6 + 2)`
* `3 ^ 2`

::: {.callout-answer collapse=true}

::: {.panel-tabset group="language"}
## R

```{r}
2 + 23
23 * 4
314 - 82
(12 - 4) * (6 + 2)
3 ^ 2
```

:::
:::
:::

### Creating scripts {#sec-exr_scripts}

:::{.callout-exercise}

{{< level 1 >}}

Please do the following:

1. Create a script called `session_01` in your working directory.
2. Re-run the calculations from [Exercise -@sec-exr_calculations].
3. Save the changes to the script.

:::

### Adding functionality {#sec-exr_packages}

:::{.callout-exercise}

{{< level 1 >}}

It's important that you are comfortable with adding functionality.

::: {.panel-tabset group="language"}
## R

Please install the `tidyverse` package *using the console*.

Then, in the script you created in [Exercise -@sec-exr_scripts] load it into R.
:::

::: {.callout-answer collapse=true}

::: {.panel-tabset group="language"}
## R

We can install the package as follows:

```{r}
#| eval: false
install.packages("tidyverse")
```

Note that the title of the package needs to be in quotes (`" "`).

We load the package by running the following line of code from our script:

```{r}
#| eval: false
library(tidyverse)
```

Note that, rather inconsistently, we do *not* use quotes around the package name when loading it.
:::
:::
:::


## Summary

Expand Down

0 comments on commit ddd015f

Please sign in to comment.