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

Glue Pipelines

20180729 We can use glue::glue_data() within pipes and operate over the rows of the data that is piped into the operator.
weatherAUS %>%
  sample_n(6) %>%
  glue_data("Observation",
            " {rownames(.) %>% as.integer() %>% comma() %>% sprintf('%7s', .)}",
            " location {Location %>% sprintf('%-14s', .)}",
            " max temp {MaxTemp %>% sprintf('%5.1f', .)}")
## Observation     1.0 location Hobart         max temp  27.3
## Observation     2.0 location Witchcliffe    max temp  29.3
## Observation     3.0 location Brisbane       max temp  26.7
## Observation     4.0 location PerthAirport   max temp  20.8
## Observation     5.0 location Brisbane       max temp  21.1
## Observation     6.0 location PearceRAAF     max temp  26.6
....

It can also be useful with the tidy verse work flow.

weatherAUS %>%
  sample_n(6) %>%
  mutate(TempRange = glue("{MinTemp}-{MaxTemp}")) %>%
  glue_data("Observed temperature range at {Location} of {TempRange}")
## Observed temperature range at Williamtown of 7.7-19.7
## Observed temperature range at Albury of 15.3-34.9
## Observed temperature range at Sydney of 18.1-27.5
## Observed temperature range at Canberra of 11.8-25.7
## Observed temperature range at Nuriootpa of 14.1-30.7
## Observed temperature range at Dartmoor of 5.1-16.9
....


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.