Created
May 2, 2021 09:54
-
-
Save ranjiGT/6f880faf62dd77c94a49c278621de88d to your computer and use it in GitHub Desktop.
A touch up script in R for problem-solving
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) | |
category <- c("red", "blue", "green", "yellow") | |
tag <- c("yes", "no", "maybe", "idk") | |
value <- c(21, 1, 10, 9) | |
df <- data.frame(category, tag, value) %>% | |
mutate(prop = value/sum(value)) | |
df %>% | |
ggplot(aes(tag, prop, fill = category))+ | |
geom_col()+ | |
geom_text(aes(label = prop %>% scales::percent()), position=position_dodge(width=0.9), vjust=-0.25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment