Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Pipeline

20210103 Suppose we want to produce a base::summary() of a selection of numeric variables. We can pipe the output of dplyr::select() into base::summary().
# Select variables from the dataset and summarise the result.

ds %>%
  select(min_temp, max_temp, rainfall, sunshine) %>%
  summary()
##     min_temp        max_temp        rainfall          sunshine    
##  Min.   :-8.70   Min.   :-4.10   Min.   :  0.000   Min.   : 0.00  
##  1st Qu.: 7.50   1st Qu.:18.10   1st Qu.:  0.000   1st Qu.: 4.90  
##  Median :12.00   Median :22.80   Median :  0.000   Median : 8.50  
##  Mean   :12.15   Mean   :23.36   Mean   :  2.241   Mean   : 7.66  
##  3rd Qu.:16.90   3rd Qu.:28.40   3rd Qu.:  0.600   3rd Qu.:10.60  
##  Max.   :33.90   Max.   :48.90   Max.   :474.000   Max.   :14.50  
....

Perhaps we would like to review only those observations where there is more than a little rain on the day of the observation. To do so we stats::filter() the observations.

# Select specific variables and observations from the dataset.

ds %>%
  select(min_temp, max_temp, rainfall, sunshine) %>%
  filter(rainfall >= 1)
## # A tibble: 39,122 x 4
##    min_temp max_temp rainfall sunshine
##       <dbl>    <dbl>    <dbl>    <dbl>
##  1     17.5     32.3      1         NA
##  2     13.1     30.1      1.4       NA
##  3     15.9     21.7      2.2       NA
....

This sequence of functions operating on the original rattle::weatherAUS dataset returns a subset of that dataset where all observations have at least 1mm of rain.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.