Skip to content

Commit

Permalink
Organizing and struturing practice session 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
camilavargasp committed Jan 11, 2024
1 parent 2cb27fc commit 5f5453c
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 18 deletions.
6 changes: 3 additions & 3 deletions materials/sections/exercise-intro-programming-socialsci.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ by clicking the "more info" link next to the file name at the top of the
page.**

::: callout-note
## Session's Goal
## Big Idea

The goal for this session is to practice downloading data, reading it
into R in a Quarto document, using base R commands to summarize a
variable within the dataset, and practice formatting a Quarto document
using Markdown syntax.
:::

## Exercise I
## Exercise 1

::: callout-tip
## Set up
Expand Down Expand Up @@ -133,7 +133,7 @@ Calculate the mean of the answers to Question 3 and save this value into
an object in your Global Environment.

**Tip:** Look at the help page if your answer isn't what you expect,
`?mean()`. Does Q3 column contan `NA` values?
`?mean()`. Does Q3 column have `NA` values?
:::


Expand Down
86 changes: 74 additions & 12 deletions materials/sections/exercise-tidyverse-socialsci.qmd
Original file line number Diff line number Diff line change
@@ -1,23 +1,85 @@
## Learning Objectives {.unnumbered}

- practice tidyverse R skills
- Practice cleaning and wrangling data
- Practice using `dplyr` and `tidyr` functions
- Learn how to use the `tibble::tibble()` function to create a data frame

### Introduction
## Introduction

In this session of R practice, we will continue working with the dataset: [Tobias Schwoerer, Kevin Berry, and Jorene Joe. 2022. A household survey documenting experiences with coastal hazards in a western Alaska community (2021-2022). Arctic Data Center. doi:10.18739/A29Z90D3V.](https://doi.org/10.18739/A29Z90D3V)

In this practice session, we will build upon the previous session by using `dplyr`, `tidyr`, and other packages form the tidyverse to create more summarizations of the survey answers.
::: callout-tip
## Big Idea

### High level steps
In this practice session, we will build upon the previous session by using `dplyr`, `tidyr`, and other packages form the tidyverse to summarize answers of the survey.
:::

- work in the same Rmd you did during R practice I
- add necessary headers and text to describe what you are doing during this practice
- using `group_by` and `summarize`, calculate how many responses there were to each unique answer for question 3
- create a `data.frame` containing the definitions to the answer codes in question 3
- use the metadata to get code-definition pairs
- create your `data.frame` either by writing a new file and reading it in, or by exploring the function `tribble` (see the examples)
- use a `left_join` to join your definitions table to the summarized answers
## Exercise 2

#### Bonus {.unnumbered}
::: callout-tip
## Set up

- Work in the same Qmd you did during R practice 1.
- Add necessary headers and text to describe what you are doing during this practice.
- Using Split-Apply-Combine strategy
- Creating a Data Frame
- Joining Data Frames

- At the top of your document, one line below the three dashed line from the YAML, add a level 2 header called Setup followed by a new code chunk to load the necessary libraries.

```{r}
library(readr)
library(dplyr)
library(tidyr)
library(tibble)
```


:::

### Using Split-Apply-Combine strategy

::: callout-note
## Step 1

Use `group_by` and `summarize` to calculate how many responses there were to each unique answer for question 3.
:::


::: {.callout-note appearance="minimal" collapse="true"}
## Example Code


```{r}
#q3_summary <-
```

:::

### Creating a Data Frame

::: callout-note
## Step 2
Create a `data.frame` containing the definitions to the answer codes in Question 3. Use the [metadata](https://arcticdata.io/catalog/view/doi%3A10.18739%2FA29Z90D3V#urn%3Auuid%3Aab696e67-8ed0-4900-b568-4ee576bc87bd) to get code-definition pairs.

One way of creating a new data frame is by using the `tribble()` or `tibble()` functions from the [`tibble` package](https://tibble.tidyverse.org/index.html).

**Tip:** Search either in the help page or on the web for information about `tribble()` or `tibble()`. Then decide which on to use to create a new data frame.

:::

### Joining Data Frames

::: callout-note
## Step 3
Use a `left_join` to join your definitions table to the summarized answers
:::

## Bonus

::: callout-note
## Go Further
Explore how you might summarize other questions in these survey results.
:::
1 change: 0 additions & 1 deletion materials/session_07.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ execute:




{{< include /sections/exercise-intro-programming-socialsci.qmd >}}
7 changes: 5 additions & 2 deletions materials/session_12.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

---
title: "Practice Session II"
title: "R Practice: Cleaning and Wrangling"
title-block-banner: true
execute:
eval: false
---



{{< include /sections/exercise-tidyverse-socialsci.qmd >}}

0 comments on commit 5f5453c

Please sign in to comment.