9.8 Shuffle Rows

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

ds %>% sample_frac()
## # A tibble: 226,868 × 24
##    date       location         min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>               <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2019-08-10 Portland              2.5     11.8     24          NA       NA  
##  2 2020-02-02 MelbourneAirport     12.9     24.4     15.6         4.4      9  
##  3 2015-07-06 Cairns               19       26.5      1           2.2      6.9
##  4 2022-03-15 MelbourneAirport     16.3     26        0           6.2      3.6
##  5 2022-10-15 GoldCoast            15.9     24.6      0          NA       NA  
##  6 2022-10-25 SalmonGums            7       21.6      5.4        NA       NA  
##  7 2017-11-28 CoffsHarbour         17       27.2      0          NA       NA  
##  8 2018-11-08 PerthAirport          6.1     29.2      0           7.2     12.2
##  9 2014-09-27 Canberra              4.1     18.2      0          NA       NA  
## 10 2018-03-05 Wollongong           19.4     20.9      0          NA       NA  
## # ℹ 226,858 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