9.7 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: 275,410 × 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
## # ℹ 275,400 more rows


If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, 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