9.6 Selecting Columns

20200317

Columns from a data frame can be dplyr::select()’ed simply by listing the column names. The columns in the resulting data frame will be in the same order as they are listed in the function call.

ds %>%
  select(date, location, min_temp, temp_9am, temp_3pm, max_temp)
## # A tibble: 226,868 × 6
##    date       location min_temp temp_9am temp_3pm max_temp
##    <date>     <chr>       <dbl>    <dbl>    <dbl>    <dbl>
##  1 2008-12-01 Albury       13.4     16.9     21.8     22.9
##  2 2008-12-02 Albury        7.4     17.2     24.3     25.1
##  3 2008-12-03 Albury       12.9     21       23.2     25.7
##  4 2008-12-04 Albury        9.2     18.1     26.5     28  
##  5 2008-12-05 Albury       17.5     17.8     29.7     32.3
##  6 2008-12-06 Albury       14.6     20.6     28.9     29.7
##  7 2008-12-07 Albury       14.3     18.1     24.6     25  
##  8 2008-12-08 Albury        7.7     16.3     25.5     26.7
##  9 2008-12-09 Albury        9.7     18.3     30.2     31.9
## 10 2008-12-10 Albury       13.1     20.1     28.2     30.1
## # ℹ 226,858 more rows


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0