Guest User

Untitled

a guest
Dec 15th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. library(tidyverse)
  2. library(here)
  3. library(ggsci)
  4. df.alpha <- read_csv("online.csv")
  5.  
  6. ggplot(df.alpha, aes(Margin)) +
  7. geom_density(aes(fill=Side), alpha=0.5) +
  8. scale_fill_npg()
  9.  
  10. tmp <- df.alpha %>% unite("id", c("Order", "Name"), sep = ".") %>% arrange(-Margin)
  11. tmp$id <- factor(tmp$id, levels=tmp$id)
  12. ggplot(tmp, aes(y=Margin)) +
  13. geom_bar(aes(x=id, fill=Side), stat="identity") +
  14. coord_flip() + scale_fill_npg()
  15.  
  16.  
  17. tmp <- df.alpha %>% unite("id", c("Order", "Name"), sep = ".") %>% arrange(Order)
  18. tmp$id <- factor(tmp$id, levels=tmp$id)
  19.  
  20. tmp %>% ggplot(aes(y=Margin)) +
  21. geom_bar(aes(x=id, fill=Side), stat="identity") +
  22. coord_flip() + scale_fill_npg() + scale_y_reverse()
Add Comment
Please, Sign In to add comment