Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dplyr)
- library(magrittr)
- counts <- df %>%
- group_by(source, round) %>%
- summarize(Freq = n())
- counts2 <- counts %>%
- group_by(source) %>%
- summarise(Freq = sum(Freq)) %>%
- arrange(desc(Freq)) %>% head(10)
- counts <- counts %>% filter( source %in% counts2$source)
- #"#ff3333", "#00cc66"
- ########################
- colors <- c('#d9b3ff', '#000000', '#7300e6', '#a64dff', '#8000ff', '#330066',
- '#99ccff', '#0039e6', '#3366ff', '#809fff', '#99b3ff', '#e6ecff')
- ggplot(counts, aes(x = candidate, y = Freq, fill = source)) +
- geom_bar(position = position_stack(), stat = "identity", width = .7) +
- labs(title = "Frequency by candidate\n", x = "", y = "Frequency\n") +
- theme_light()+
- theme(text = element_text(size=20)) +
- coord_flip() +
- scale_fill_manual(values=colors)
Add Comment
Please, Sign In to add comment