Created
October 9, 2022 02:59
-
-
Save juanchiem/2c58b65ccc3f35ac2581502b05cfe984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Author
juanchiem
commented
Oct 9, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment