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: 208,495 × 24
##    date       location   min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>         <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2013-10-07 Hobart          3.3     13.7      0           7.4      8.6
##  2 2017-07-20 PearceRAAF     11.6     18       12          NA        7.7
##  3 2009-10-03 Darwin         25.5     33        0           5.2     10.1
##  4 2017-12-28 Ballarat       20.1     30.4      0          NA       NA  
##  5 2013-03-08 Sale           15.3     32.6      0           5.8     11.6
##  6 2013-07-09 Mildura        -0.2     12.7      0           1.4      1.3
##  7 2013-03-10 GoldCoast      20       28.1      2.8        NA       NA  
##  8 2021-08-23 Dartmoor        5.2     12.7      4          NA       NA  
##  9 2017-05-04 Mildura         2       18.1      0           3       NA  
## 10 2009-02-02 Adelaide       28.3     38.8      0          24       11  
## # ℹ 208,485 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