+ - 0:00:00
Notes for current slide
Notes for next slide

make a reprex…… please

👋 @sharlagelfand

make-a-reprex-please.netlify.app

your code will eventually break

you will look for help

Source: https://xkcd.com/979/

Source: https://xkcd.com/979/

you will have to ask for help

you will have to send someone your code

library(dplyr)
mtcars %>%
filter(cyl = 6)
## Error: Problem with `filter()` input `..1`.
## x Input `..1` is named.
## ℹ This usually means that you've used `=` instead of `==`.
## ℹ Did you mean `cyl == 6`?
library(dplyr)
# Why does this return no records?!
dogs %>%
filter(is_cute)
## # A tibble: 0 x 1
## # … with 1 variable: is_cute <lgl>
library(dplyr)
library(ggplot2)
library(readxl)
library(tidytext)
library(janitor)
library(lubridate)
# Read data
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
# Clean data
data <- data %>%
clean_names() # Make names look nice
# Add year
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.

"reproducible example"

"If you need help getting unstuck, the first step is to create a reprex, or reproducible example. The goal of a reprex is to package your problematic code in such a way that other people can run it and feel your pain. Then, hopefully, they can provide a solution and put you out of your misery."

https://www.tidyverse.org/help/

"If you need help getting unstuck, the first step is to create a reprex, or reproducible example. The goal of a reprex is to package your problematic code in such a way that other people can run it and feel your pain. Then, hopefully, they can provide a solution and put you out of your misery."

https://www.tidyverse.org/help/

"If you need help getting unstuck, the first step is to create a reprex, or reproducible example. The goal of a reprex is to package your problematic code in such a way that other people can run it and feel your pain. Then, hopefully, they can provide a solution and put you out of your misery."

https://www.tidyverse.org/help/

"other people can run it"

☝ libraries

✌ code

👌 data

library(dplyr)
library(ggplot2)
library(readxl)
library(tidytext)
library(janitor)
library(lubridate)
# Read data
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
# Clean data
data <- data %>%
clean_names() # Make names look nice
# Add year
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.
library(dplyr)
library(ggplot2)
library(readxl)
library(tidytext)
library(janitor)
library(lubridate)
# Read data
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
# Clean data
data <- data %>%
clean_names() # Make names look nice
# Add year
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.
library(dplyr)
library(readxl)
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.

what if i don't know what code to include?

what if i don't know what code to include?

add one line until it breaks

what if i don't know what code to include?

add one line until it breaks

remove one line until it works... then add back the broken line

library(dplyr)
library(readxl)
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))

make fake data inline

library(dplyr)
tibble(x = c(1, 2), y = c(2, 4))
## # A tibble: 2 x 2
## x y
## <dbl> <dbl>
## 1 1 2
## 2 2 4

make fake data inline

library(dplyr)
tibble(x = c(1, 2), y = c(2, 4))
## # A tibble: 2 x 2
## x y
## <dbl> <dbl>
## 1 1 2
## 2 2 4
tribble(
~x, ~y,
1, 2,
2, 4
)
## # A tibble: 2 x 2
## x y
## <dbl> <dbl>
## 1 1 2
## 2 2 4
library(dplyr)
library(readxl)
setwd("/Users/sharla/Documents/my_work_folder/project_1/data")
data <- read_xlsx("Export 2021-01-02 V5.xlsx")
data %>%
mutate(year = case_when(date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.
library(dplyr)
tibble(date = "2020-01-01") %>%
mutate(year = case_when(
date <= "2020-12-31" & date >= "2020-01-01" ~ 2020,
is.na(date) ~ NA
))
## Error: Problem with `mutate()` input `year`.
## x must be a double vector, not a logical vector.
## ℹ Input `year` is `case_when(...)`.

"and feel your pain"

people are better at understanding output than you'd expect

but how?

reprex package

🪐 isolated

🤝 code + output

🏦 different venues

🖼 images

more live coding

for later: code and issues

you will feel great

the odds of someone helping you increase by 1000%

(please do not try to reproduce my findings)

but you might not even need to ask for help

it's common to solve your problem through the act of creating the reprex

Shannon Pileggi for @WeAreRLadies

Shannon Pileggi for @WeAreRLadies

your code will eventually break

you will look for help

Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow