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: 191,431 x 24
##    date       location     min_temp max_temp rainfall evaporation sunshine
##    <date>     <chr>           <dbl>    <dbl>    <dbl>       <dbl>    <dbl>
##  1 2009-10-18 Launceston        5.7     16.9      0          NA       NA  
##  2 2015-09-16 MountGinini      -1.6      9.9      0.2        NA       NA  
##  3 2019-08-15 Tuggeranong      -5.2     15.6      0          NA       NA  
##  4 2013-05-12 PearceRAAF        5.9     20.8     NA          NA        7.6
##  5 2009-07-18 Cairns           13.4     26.1      0           6.2      9.1
##  6 2017-03-02 Walpole          16.1     34        0          NA       NA  
##  7 2011-11-03 Albury            9.3     22.3      0          NA       NA  
##  8 2008-07-15 Brisbane         16.7     24.8      0           1.2      5.9
##  9 2014-02-08 Williamtown      12.4     30.9     NA          NA       NA  
## 10 2017-11-30 AliceSprings     24.8     38        0          NA       NA  
## # … with 191,421 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 the 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.