Tidyverse

Tidyverse is one suite of tools for data science

Exploratory Data Analysis

url <- "https://github.com/hadley/r4ds/raw/master/diagrams/data-science.png"
knitr::include_graphics(url)

Tidyverse Basic Principles

IMPORT (readr):
- read_csv()
- read_delim()

TIDY & TRANSFORM (dplyr):
- mutate() adds new variables that are functions of existing variables
- select() picks variables based on their names.
- filter() picks cases based on their values.
- summarise() reduces multiple values down to a single summary.
- arrange() changes the ordering of the rows.

VISUALISE (ggplot): creating graphics, based on ‘The Grammar of Graphics’
- aes()
- geom_x() + layers

MODEL (broom):
- tidy(), glance(), augment()


url <- "https://s3-us-west-2.amazonaws.com/collections.lacma.org-images/remote_images/ma-150089-WEB.jpg"
knitr::include_graphics(url)

magrittr package

url <- "https://github.com/tidyverse/magrittr/raw/master/man/figures/logo.png"
knitr::include_graphics(url)

magrittr package

magrittr package by Stefan Milton Bache developed the concept of the pipe, which is used heavily in the tidyverse

url <- "https://github.com/tidyverse/magrittr/raw/master/vignettes/magrittr.jpg"
knitr::include_graphics(url)



"and then"

The Pipe {.build}

The “pipe” is a sequence of functions, that are sequentially applied to an object

wakeup(self) %>%
  put_on("clothes") %>%
  eat("breakfast") %>%
  go(to = "work")

Alternative nested code:

go(eat(put_on(wakeup(self), "clothes"), "breakfast"), to = "work")

The Pipe (Quiz I)

What does this code do?

wakeup(self) %>%
  put_on("clothes") %>%
  eat("breakfast") %>%
  fmk() %>% 
  go(to = "work")

The Pipe (Quiz II)

What does this code do?

morning_routine <- wakeup(self) %>%
  put_on("clothes") %>%
  eat("breakfast") %>%
  fmk() %>% 
  go(to = "work")

The Pipe (Quiz III)

What does this code do?

`r dataframe_name %>%select(r colnames(df_numeric_select), r colnames(df_character_select)) %>%group_by(r colnames(df_character_select)) %>%summarize(mean(r colnames(df_numeric_select)))`


Writing code IS NOT like drawing an owl

url <- "https://66.media.tumblr.com/tumblr_l7iwzq98rU1qa1c9eo1_500.jpg"
knitr::include_graphics(url)

Writing code IS a step-wise process

#change this to a good "and then" example
url <- "https://github.com/rstudio-education/datascience-box/raw/master/slides/u1_d01-meet-the-toolkit/img/lego-steps.png"
knitr::include_graphics(url)

https://datasciencebox.org



matthewhirschey/bespokelearnr documentation built on Oct. 11, 2020, 12:57 a.m.