Suggestions from Marie
This commit is contained in:
@@ -419,19 +419,22 @@ There are many functions for creating new variables that you can use with `mutat
|
||||
start with `min_rank()`. It does the most usual type of ranking
|
||||
(e.g. 1st, 2nd, 2nd, 4th). The default gives smallest values the small
|
||||
ranks; use `desc(x)` to give the largest values the smallest ranks.
|
||||
If `min_rank()` doesn't do what you need, look at the variants
|
||||
`row_number()`, `dense_rank()`, `percent_rank()`, `cume_dist()`,
|
||||
`ntile()`.
|
||||
|
||||
```{r}
|
||||
y <- c(1, 2, 2, NA, 3, 4)
|
||||
tibble(
|
||||
row_number(y),
|
||||
min_rank(y),
|
||||
dense_rank(y),
|
||||
percent_rank(y),
|
||||
cume_dist(y)
|
||||
)
|
||||
min_rank(y)
|
||||
min_rank(desc(y))
|
||||
```
|
||||
|
||||
If `min_rank()` doesn't do what you need, look at the variants
|
||||
`row_number()`, `dense_rank()`, `percent_rank()`, `cume_dist()`,
|
||||
`ntile()`. See their help pages for more details.
|
||||
|
||||
```{r}
|
||||
row_number(y)
|
||||
dense_rank(y)
|
||||
percent_rank(y)
|
||||
cume_dist(y)
|
||||
```
|
||||
|
||||
### Exercises
|
||||
|
||||
Reference in New Issue
Block a user