Skip to content

Commit

Permalink
Merge pull request #529 from jessesadler/plot-data-clean
Browse files Browse the repository at this point in the history
Replace NULL with NA in interviews_plotting
  • Loading branch information
jessesadler authored Sep 27, 2024
2 parents b85c073 + 06dcc61 commit 0bb09e1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 41 deletions.
2 changes: 1 addition & 1 deletion episodes/05-ggplot2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ interviews_plotting <- read_csv("https://raw.githubusercontent.com/datacarpentry
## Can be used to load in data from previous lesson!
interviews_plotting <- interviews %>%
## pivot wider by items_owned
separate_rows(items_owned, sep = ";") %>%
separate_longer_delim(items_owned, delim = ";") %>%
## if there were no items listed, changing NA to no_listed_items
replace_na(list(items_owned = "no_listed_items")) %>%
mutate(items_owned_logical = TRUE) %>%
Expand Down
4 changes: 4 additions & 0 deletions episodes/data/download_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ library(dplyr)
if (! file.exists("data/interviews_plotting.csv")) {
# Copy code from ggplot episode to create data
interviews_plotting <- df %>%
# Need to turn NULL to NA
mutate(memb_assoc = na_if(memb_assoc, "NULL"),
affect_conflicts = na_if(affect_conflicts, "NULL"),
items_owned = na_if(items_owned, "NULL")) %>%
separate_rows(items_owned, sep = ";") %>%
replace_na(list(items_owned = "no_listed_items")) %>%
mutate(items_owned_logical = TRUE) %>%
Expand Down
Loading

0 comments on commit 0bb09e1

Please sign in to comment.