Guest User

Untitled

a guest
Jan 19th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. library(dplyr)
  2. library(ggplot2)
  3. library(scales)
  4. library(reshape2)
  5. library(tibble)
  6.  
  7. Prepare data
  8. file="C:...../Desktop/pa.csv"
  9. df <- read.csv(file, header=TRUE, sep=",") %>%
  10.  
  11. rownames_to_column( var = "country" ) %>% # tibble
  12. head(country)
  13. mutate_each(funs(rescale), -country) %>% # scales
  14. melt(id.vars=c('country'), measure.vars=colnames(file)) %>%
  15. arrange(country)
  16.  
  17. Facet by variable
  18. df %>%
  19. ggplot(aes(x=country, y=value, group=variable, color=variable)) +
  20. geom_polygon(fill=NA) +
  21. coord_polar() + theme_bw() + facet_wrap(~ variable) +
  22. #scale_x_discrete(labels = abbreviate) + # Can increase the text size and uncomment
  23. theme(axis.text.x = element_text(size = 3))
  24.  
  25. var1, var2, var3, var4, var5, var6
  26. c1,1,3,3,3,2
  27. c2,2,4,3,4,4
  28. c3,5,5,3,3,5
  29. c4,4,4,2,3,3
  30. c5,4,4,3,4,5
  31. c6,5,5,3,2,5
  32. c7,5,5,4,5,5
  33. c8,5,5,4,4,5
  34. c9,4,4,2,3,3
  35. c10,4,3,2,2,2
  36. c11,5,4,3,5,5
  37. c12,4,4,3,3,3
  38. c13,3,2,3,3,1
  39. c14,3,2,2,3,4
Add Comment
Please, Sign In to add comment