Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaning lecture improvement #216

Open
4 tasks
carriewright11 opened this issue Oct 7, 2024 · 2 comments
Open
4 tasks

cleaning lecture improvement #216

carriewright11 opened this issue Oct 7, 2024 · 2 comments

Comments

@carriewright11
Copy link
Contributor

  • Slide 49 should be be changing to uppercase Dioxin
  • maybe remove regex from the final case_when example but could mention on a diff slide
  • maybe add back the example of sometimes you want NA with case_when
  • Maybe simplify the recoding?
@carriewright11 carriewright11 changed the title cleaning lecture imrpovement cleaning lecture improvement Oct 7, 2024
@carriewright11
Copy link
Contributor Author

carriewright11 commented Oct 7, 2024

  • could add extra slides with fancier examples and explaining when case_when is not needed:

library(tidyverse)

ces <- read_csv(file = "https://daseh.org/data/CalEnviroScreen_data.csv")

more complicated case_when example with 2 columns:

ces %>% mutate(new_col_case_when = case_when(Longitude < -121 & Latitude > 37.8 ~ "Distract A", TRUE ~ "District B")) %>% pull(new_col_case_when)

don't need case_when if just doing a calcuation with other variables:

ces %>% mutate(num_col_mutate = Longitude * Latitude ) %>% pull(num_col_mutate)

more complicated example - will get NA values (on purpose - no TRUE statement) of calculation for cases where the condition is not met:

ces %>% mutate(num_new = case_when(Longitude < -121 & Latitude > 37.8 ~ Longitude * Latitude)) %>% pull(num_new)

@carriewright11
Copy link
Contributor Author

could also add an extra slide about n_complete_row

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant