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: 176,747 x 24
##    date       location     min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>           <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2019-07-12 Mildura           9.9     17.5      0           7        5.3
##  2 2019-10-16 Dartmoor          8.2     17.2      3.8        NA       NA  
##  3 2017-09-15 Woomera           6.5     23.6      0          NA       NA  
##  4 2018-12-24 Adelaide         15.6     37        0          NA       NA  
##  5 2010-09-08 Brisbane         11.6     23.8      0           4       10.2
##  6 2018-01-09 Witchcliffe      12.7     26.7      0          NA       NA  
##  7 2012-11-18 Brisbane         17.5     26.1     64          NA        2.9
##  8 2017-03-18 PerthAirport     16.2     20.5      0.4         5.4      0.1
##  9 2015-07-12 Moree             4.8     13       NA          NA       NA  
## 10 2016-01-09 Bendigo          12       34.8     NA          NA       NA  
## # … with 176,737 more rows, and 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 development 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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.