-
Notifications
You must be signed in to change notification settings - Fork 6
/
sac-assessment.Rmd
70 lines (52 loc) · 1.7 KB
/
sac-assessment.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
layout: page
title: RStudio Trainer Program
subtitle: "Tidyverse: Split-Apply-Combine Strategy - Assessment"
author:
name: xwMOOC
url: https://www.facebook.com/groups/tidyverse/
affiliation: Tidyverse Korea
date: "`r Sys.Date()`"
output:
html_document:
toc: yes
toc_float: true
highlight: tango
code_folding: show
number_section: true
self_contained: true
editor_options:
chunk_output_type: console
---
``` {r, include=FALSE}
# source("tools/chunk-options.R")
knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE,
comment="", digits = 3, tidy = FALSE, prompt = FALSE, fig.align = 'center')
```
# Multiple Choice Question {#sac-multiple-choice}
Split-Apply-Combine strategy is an attractive conceptual model in terms of removing `for` loops. from the following R workflow, which is the Split-Apply-Combine strategy?
1. `split` → `lapply` → `do.call`
1. `ddplyr`: `.data`, `.variable`, `.fun`
1. `tidyverse`: `group_by`, `do`
1. `split` → `map_dfr`
1. `group_by` → `nest()` → `mutate(map())`
1. All of them
Hint: [R 병렬 프로그래밍 - "분할-적용-병합(Split-Apply-Combine) 전략"](https://statkclee.github.io/parallel-r/r-parallel-split-apply-combine.html)
# Parsons Problems {#sac-parsons-problem}
<div class = "row">
<div class = "col-md-4">
**Instruction**
- Use `iris_tbl` dataframe
- Group by `Species`, and then `nest()`
- Calculate `Sepal.Length` mean through `mutate()`, `map()` pattern
</div>
<div class = "col-md-8">
**Write Code**
```{r gapminder-sac, eval=FALSE}
iris_tbl %>%
____(Species) %>%
nest() %>%
____(mean_sepal_length = map____(data, ~mean(.$`_____`)))
```
</div>
</div>