Skip to content

Commit

Permalink
Continuing to rewrite data-transform
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 21, 2021
1 parent 0c4b8dc commit 5f45c33
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 83 deletions.
1 change: 1 addition & 0 deletions _bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rmd_files: [
"workflow-basics.Rmd",
"data-transform.Rmd",
"data-tidy.Rmd",
"workflow-pipes.Rmd",
"data-import.Rmd",
"workflow-scripts.Rmd",
"EDA.Rmd",
Expand Down
166 changes: 89 additions & 77 deletions data-transform.Rmd

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion logicals-numbers.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,3 @@ near(1 / 49 * 49, 1)

1. What trigonometric functions does R provide?
2.

12 changes: 8 additions & 4 deletions missing-values.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
library(tidyverse)
```

Missing topics:

- Missing values generated from matching data frames (i.e. `left_join()` and `anti_join()`

- Last observation carried forward and `tidy::fill()`

- `coalesce()` and `na_if()`

## Basics

### Missing values {#missing-values-filter}
Expand Down Expand Up @@ -167,7 +175,3 @@ arrange(df, desc(x))
## Exercises

1. Why is `NA ^ 0` not missing? Why is `NA | TRUE` not missing? Why is `FALSE & NA` not missing? Can you figure out the general rule? (`NA * 0` is a tricky counterexample!)

### Missing matches

Discuss `anti_join()`
2 changes: 2 additions & 0 deletions strings.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ str_sort(x, locale = "en") # English
str_sort(x, locale = "haw") # Hawaiian
```

TODO: add connection to `arrange()`

### Exercises

1. In code that doesn't use stringr, you'll often see `paste()` and `paste0()`.
Expand Down
1 change: 0 additions & 1 deletion vector-tools.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,3 @@ You can learn more about useful window functions in the corresponding vignette:
Use that information to rank the carriers.
8.
28 changes: 28 additions & 0 deletions workflow-pipes.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Workflow: pipes {#workflow-pipes}

- Indenting and line breaks

```{r, eval = FALSE}
df %>% mutate(y = x + 1)
# vs
df %>%
mutate(
y = x + 1
)
```
- `mutate(df, y = x + 1)` vs `df %>% mutate(df, y = x + 1)`
- with ggplot2
```{r, eval = FALSE}
df %>%
ggplot(aes())
```
Don't forget to switch to plus!
- How long should your pipes be?
Too long vs too short
- Restyling with style.

0 comments on commit 5f45c33

Please sign in to comment.