Get code working again
This commit is contained in:
parent
78ab61f284
commit
c88a907d4a
|
@ -4,6 +4,11 @@
|
|||
|
||||
`between()`
|
||||
|
||||
```{r}
|
||||
library(tidyverse)
|
||||
library(nycflights13)
|
||||
```
|
||||
|
||||
## Logical operators
|
||||
|
||||
Multiple arguments to `filter()` are combined with "and": every expression must be true in order for a row to be included in the output.
|
||||
|
@ -57,6 +62,9 @@ You'll learn how to create new variables shortly.
|
|||
This makes `sum()` and `mean()` very useful: `sum(x)` gives the number of `TRUE`s in `x`, and `mean(x)` gives the proportion.
|
||||
|
||||
```{r}
|
||||
not_cancelled <- flights %>%
|
||||
filter(!is.na(dep_delay), !is.na(arr_delay))
|
||||
|
||||
# How many flights left before 5am? (these usually indicate delayed
|
||||
# flights from the previous day)
|
||||
not_cancelled %>%
|
||||
|
@ -108,7 +116,7 @@ There's no way to list every possible function that you might use, but here's a
|
|||
If you need rolling aggregates (i.e. a sum computed over a rolling window), try the RcppRoll package.
|
||||
|
||||
```{r}
|
||||
x
|
||||
x <- 1:10
|
||||
cumsum(x)
|
||||
cummean(x)
|
||||
```
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
## Introduction
|
||||
|
||||
```{r}
|
||||
library(tidyverse)
|
||||
```
|
||||
|
||||
## Basics
|
||||
|
||||
### Missing values {#missing-values-filter}
|
||||
|
|
|
@ -1056,6 +1056,10 @@ So far you've learned how to tidy `table2`, `table4a`, and `table4b`, but not `t
|
|||
To fix this problem, we'll need the `separate()` function.
|
||||
You'll also learn about the complement of `separate()`: `unite()`, which you use if a single variable is spread across multiple columns.
|
||||
|
||||
```{r}
|
||||
library(tidyr)
|
||||
```
|
||||
|
||||
### Separate
|
||||
|
||||
`separate()` pulls apart one column into multiple columns, by splitting wherever a separator character appears.
|
||||
|
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
`%in%`
|
||||
|
||||
```{r}
|
||||
library(tidyverse)
|
||||
library(nycflights13)
|
||||
|
||||
not_cancelled <- flights %>%
|
||||
filter(!is.na(dep_delay), !is.na(arr_delay))
|
||||
```
|
||||
|
||||
## Counts
|
||||
|
||||
- Counts: You've seen `n()`, which takes no arguments, and returns the size of the current group.
|
||||
|
|
Loading…
Reference in New Issue