9.9 Shuffle Rows

Using dplyr::sample_frac() with size=1 (the default) will randomly shuffle the rows of the dataset.

ds %>% sample_frac()
## # A tibble: 275,410 × 24
##    date       location    min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>          <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2022-12-13 Woomera         12       24.5      0          NA       NA  
##  2 2014-01-03 Canberra        17.2     35.5      0          NA       NA  
##  3 2010-05-23 NorahHead       10.9     17       43.4        NA       NA  
##  4 2010-01-07 Mildura         15.8     34.6      0          12       13.5
##  5 2019-07-01 Brisbane        13.8     23.5      0           2        7.3
##  6 2014-11-15 Katherine       26.5     32        0           9       NA  
##  7 2010-07-23 Darwin          22.2     32.7      0           8.2     10.9
##  8 2015-03-14 GoldCoast       21.1     28.7      0          NA       NA  
##  9 2021-07-02 Walpole          4.8     15.2      0.2        NA       NA  
## 10 2011-02-09 Tuggeranong     12.5     24.5      0          NA       NA  
## # ℹ 275,400 more rows
## # ℹ 17 more variables: wind_gust_dir <ord>, wind_gust_speed <dbl>,
## #   wind_dir_9am <ord>, wind_dir_3pm <ord>, wind_speed_9am <dbl>,
## #   wind_speed_3pm <dbl>, humidity_9am <int>, humidity_3pm <int>,
## #   pressure_9am <dbl>, pressure_3pm <dbl>, cloud_9am <int>, cloud_3pm <int>,
## #   temp_9am <dbl>, temp_3pm <dbl>, rain_today <fct>, risk_mm <dbl>,
## #   rain_tomorrow <fct>


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