Skip to content

Instantly share code, notes, and snippets.

@juanchiem
Created October 9, 2022 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanchiem/2c58b65ccc3f35ac2581502b05cfe984 to your computer and use it in GitHub Desktop.
Save juanchiem/2c58b65ccc3f35ac2581502b05cfe984 to your computer and use it in GitHub Desktop.
library(tidyverse)
dat <- tibble::tribble(
~hj, ~a_1, ~a_2, ~a_3, ~a_4, ~a_5, ~c_1, ~c_2, ~c_3, ~c_4, ~c_5,
"hb", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L,
"hb-1", 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 3L,
"hb-2", 0L, 2L, 3L, 1L, 0L, 4L, 5L, 5L, 8L, 10L,
"hb-3", 3L, 7L, 3L, 5L, 7L, 2L, 8L, 14L, 14L, 10L
)
dat %>%
pivot_longer(-hj,
names_to = c("trt", "rep"),
names_sep = "_") %>%
mutate(hj = fct_rev(factor(factor(hj)))) %>%
group_by(trt, hj) %>%
summarise(sev = mean(value)) %>%
ungroup()-> long
long %>%
ggplot(aes(x=trt, y=hj, fill=sev))+
geom_tile(col="white", lwd = 2)+
scale_fill_gradient(low="green", high="red2", limits=c(0, 20))+
geom_text(aes(label = sev), color = "white", size = 4) +
# theme(panel.grid.minor = element_line(colour="grey", size=0.5),
# axis.text.x = element_text(angle = 45, hjust = 1),
# legend.position="top",
# legend.box="horizontal") +
guides(fill="none")
@juanchiem
Copy link
Author

image

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