Skip to content

Commit

Permalink
%>% → |>
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheiss committed Nov 8, 2024
1 parent 5891ef6 commit 43f2d15
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
20 changes: 10 additions & 10 deletions analysis/wcnpd.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ articles <- read_csv(here("data", "manual_data", "Skimming notes_coding.csv"))

nvsq_counts <- read_csv(here("data", "manual_data", "nvsq_counts.csv"))

nvsq_counts_year <- nvsq_counts %>%
filter(Year <= 2020) %>%
# filter(Year <= 2021 & !(Year == 2021 & Issue > 3)) %>%
# mutate(Year = recode(Year, "2021" = 2020)) %>%
group_by(Year) %>%
nvsq_counts_year <- nvsq_counts |>
filter(Year <= 2020) |>
# filter(Year <= 2021 & !(Year == 2021 & Issue > 3)) |>
# mutate(Year = recode(Year, "2021" = 2020)) |>
group_by(Year) |>
summarize(total = sum(Count))

plot_data <- articles %>%
filter(year <= 2020) %>%
# mutate(year = recode(year, "2021" = 2020)) %>%
count(year) %>%
left_join(nvsq_counts_year, by = c("year" = "Year")) %>%
plot_data <- articles |>
filter(year <= 2020) |>
# mutate(year = recode(year, "2021" = 2020)) |>
count(year) |>
left_join(nvsq_counts_year, by = c("year" = "Year")) |>
mutate(pct = n / total)

nvsq_count <- ggplot(plot_data, aes(x = factor(year), y = n)) +
Expand Down
48 changes: 24 additions & 24 deletions manuscript/manuscript.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ data_confounder <- dagify(
X ~ Z,
coords = list(x = c(X = 1, Y = 3, Z = 2),
y = c(X = 1, Y = 1, Z = 2))
) %>%
tidy_dagitty() %>%
mutate(arrow_color = ifelse(name == "Z", clrs$orange, "grey80")) %>%
) |>
tidy_dagitty() |>
mutate(arrow_color = ifelse(name == "Z", clrs$orange, "grey80")) |>
mutate(node_color = ifelse(name == "Z", TRUE, FALSE))
confounder <- ggplot(data_confounder, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand All @@ -320,12 +320,12 @@ data_mediator <- dagify(
Z ~ X,
coords = list(x = c(X = 1, Y = 3, Z = 2),
y = c(X = 1, Y = 1, Z = 2))
) %>%
tidy_dagitty() %>%
) |>
tidy_dagitty() |>
mutate(arrow_color = case_when(
name == "Z" & to == "Y" ~ clrs$purple,
name == "X" & to == "Z" ~ clrs$purple,
TRUE ~ "grey80")) %>%
TRUE ~ "grey80")) |>
mutate(node_color = ifelse(name == "Z", TRUE, FALSE))
mediator <- ggplot(data_mediator, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand All @@ -345,9 +345,9 @@ data_collider <- dagify(
Z ~ X + Y,
coords = list(x = c(X = 1, Y = 3, Z = 2),
y = c(X = 1, Y = 1, Z = 2))
) %>%
tidy_dagitty() %>%
mutate(arrow_color = ifelse(to == "Z", clrs$red, "grey80")) %>%
) |>
tidy_dagitty() |>
mutate(arrow_color = ifelse(to == "Z", clrs$red, "grey80")) |>
mutate(node_color = ifelse(name == "Z", TRUE, FALSE))
collider <- ggplot(data_collider, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand Down Expand Up @@ -492,9 +492,9 @@ data_rct <- dagify(
y = c(X = 1, Y = 1, Z = 2)),
exposure = "X",
outcome = "Y"
) %>%
tidy_dagitty() %>%
node_status() %>%
) |>
tidy_dagitty() |>
node_status() |>
mutate(arrow_color = ifelse(name == "X", clrs$red, "grey80"))
rct <- ggplot(data_rct, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand All @@ -518,10 +518,10 @@ data_iv <- dagify(Y ~ X + U,
outcome = "Y",
latent = "U",
coords = list(x = c(X = 1, Y = 3, U = 2, I = 0),
y = c(X = 1, Y = 1, U = 2, I = 1))) %>%
tidy_dagitty() %>%
adjust_for(var = "I") %>%
node_status() %>%
y = c(X = 1, Y = 1, U = 2, I = 1))) |>
tidy_dagitty() |>
adjust_for(var = "I") |>
node_status() |>
mutate(arrow_color = ifelse(name == "X", clrs$red, "grey80"))
iv <- ggplot(data_iv, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand All @@ -544,10 +544,10 @@ data_diff_diff <- dagify(Y ~ X + Time + Location,
exposure = "X",
outcome = "Y",
coords = list(x = c(X = 1, Y = 3, Time = 2, Location = 2),
y = c(X = 1, Y = 1, Time = 2, Location = 0))) %>%
tidy_dagitty() %>%
adjust_for(var = c("Time", "Location")) %>%
node_status() %>%
y = c(X = 1, Y = 1, Time = 2, Location = 0))) |>
tidy_dagitty() |>
adjust_for(var = c("Time", "Location")) |>
node_status() |>
mutate(arrow_color = ifelse(name == "X", clrs$red, "grey80"))
diff_diff <- ggplot(data_diff_diff, aes(x = x, y = y, xend = xend, yend = yend)) +
Expand Down Expand Up @@ -577,10 +577,10 @@ data_rdd <- dagify(Y ~ X + Running + U,
outcome = "Y",
latent = "U",
coords = list(x = c(X = 1, Y = 4, Running = 3, Threshold = 2, U = 3),
y = c(X = 1, Y = 1, Running = 2, Threshold = 1.75, U = 3))) %>%
tidy_dagitty() %>%
adjust_for(var = c("Threshold", "Running")) %>%
node_status() %>%
y = c(X = 1, Y = 1, Running = 2, Threshold = 1.75, U = 3))) |>
tidy_dagitty() |>
adjust_for(var = c("Threshold", "Running")) |>
node_status() |>
mutate(arrow_color = ifelse(name == "X", clrs$red, "grey80"),
name = recode(name, "Running" = "Running\nvariable"),
linetype = ifelse(name == "U" & to == "X", "21", "solid"))
Expand Down

0 comments on commit 43f2d15

Please sign in to comment.