Skip to content

Commit

Permalink
Feedback from twitter
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Nov 4, 2022
1 parent 3f68594 commit eb0b19e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base-R.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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]
```
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit eb0b19e

Please sign in to comment.