Feedback from twitter
This commit is contained in:
parent
3f68594404
commit
eb0b19e641
|
@ -70,9 +70,11 @@ There are five main types of things that you can subset a vector with, i.e. that
|
|||
x <- c(10, 3, NA, 5, 8, 1, NA)
|
||||
|
||||
# All non-missing values of x
|
||||
!is.na(x)
|
||||
x[!is.na(x)]
|
||||
|
||||
# All even (or missing!) values of x
|
||||
x %% 2 == 0
|
||||
x[x %% 2 == 0]
|
||||
```
|
||||
|
||||
|
@ -123,7 +125,7 @@ We need to use it here because `[` doesn't use tidy evaluation, so you need to b
|
|||
|
||||
There's an important difference between tibbles and data frames when it comes to `[`.
|
||||
In this book we've mostly used tibbles, which *are* data frames, but they tweak some older behaviors to make your life a little easier.
|
||||
In most places, you can use tibbles and data frame interchangeably, so went we want to draw particular attention to R's built-in data frame, we'll write `data.frame`s.
|
||||
In most places, you can use tibbles and data frame interchangeably, so when we want to draw particular attention to R's built-in data frame, we'll write `data.frame`s.
|
||||
So if `df` is a `data.frame`, then `df[, cols]` will return a vector if `col` selects a single column and a data frame if it selects more than one column.
|
||||
If `df` is a tibble, then `[` will always return a tibble.
|
||||
|
||||
|
|
Loading…
Reference in New Issue