7 Workflow: pipes

  • Indenting and line breaks

    df %>% mutate(y = x + 1)
    # vs
    df %>%
      mutate(
        y = x + 1
      )
  • mutate(df, y = x + 1) vs df %>% mutate(df, y = x + 1)

  • with ggplot2

    df %>% 
      ggplot(aes()) 

    Don’t forget to switch to plus!

  • How long should your pipes be? Too long vs too short

  • Restyling with style.