From eb0b19e6410339ea27180cba8842fcc099132cac Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Fri, 4 Nov 2022 16:37:53 -0500 Subject: [PATCH] Feedback from twitter --- base-R.qmd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base-R.qmd b/base-R.qmd index f0d0cd4..f2caedb 100644 --- a/base-R.qmd +++ b/base-R.qmd @@ -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.