Last active
August 15, 2022 09:53
-
-
Save juanchiem/d0d23acebee3793d1472089436971d74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
da <- read.csv("https://raw.githubusercontent.com/juanchiem/agro_data/master/spores.csv", | |
sep = ";") | |
da %>% | |
group_by(meter, spore_nuclei, .drop=FALSE) %>% | |
summarise(count = mean(count)) %>% | |
mutate(percent = count/sum(count)) %>% | |
# group_by(meter, spore_nuclei) %>% | |
# mutate(tot = sum(count)) | |
ggplot(aes(x=meter, y=percent, fill=factor(spore_nuclei) ))+ | |
geom_bar(position="fill", stat="identity")+ | |
labs(y="Type of spore frequency")+ | |
scale_fill_viridis_d(direction = -1)+ | |
geom_text(aes(label = round(percent,2)), position = position_stack(vjust = .5), | |
col = "white", fontface = "bold", size = 3)+ | |
theme_bw() | |
# si fuera una escala de severidad agregamos la escala traffic: | |
mycols <- colorRampPalette(c("red2", "orange", "gold1", "forestgreen")) | |
myvals <- c(0, .25, .5, .75, 1) | |
da %>% | |
group_by(meter, spore_nuclei, .drop=FALSE) %>% | |
summarise(count = mean(count)) %>% | |
mutate(percent = count/sum(count)) %>% | |
ggplot(aes(x=meter, y=percent, fill=fct_rev(factor(spore_nuclei))))+ | |
geom_bar(position="fill", stat="identity")+ | |
labs(y="Type of spore frequency")+ | |
# scale_fill_viridis_d(direction = -1)+ | |
scale_fill_manual(values=mycols(5), name="Escala sev") + | |
geom_text(aes(label = round(percent,2)), position = position_stack(vjust = .5), | |
col = "white", fontface = "bold", size = 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment