Advertisement
Guest User

Untitled

a guest
Aug 18th, 2015
1,192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. #Import files, load plot and data packages, fire up the number machine.
  2. probly <- read.csv("~/Desktop/probly.csv", stringsAsFactors=FALSE)
  3. numberly <- read.csv("~/Desktop/numberly.csv", stringsAsFactors=FALSE)
  4. library(ggplot2)
  5. library(reshape2)
  6. library(scales)
  7. library(RColorBrewer)
  8.  
  9. #Melt data into column format.
  10. numberly <- melt(numberly)
  11. numberly$variable <- gsub("[.]"," ",numberly$variable)
  12. probly <- melt(probly)
  13. probly$variable <- gsub("[.]"," ",probly$variable)
  14.  
  15. #Order in the court!
  16. probly$variable <- factor(probly$variable,
  17. c("Chances Are Slight",
  18. "Highly Unlikely",
  19. "Almost No Chance",
  20. "Little Chance",
  21. "Probably Not",
  22. "Unlikely",
  23. "Improbable",
  24. "We Doubt",
  25. "About Even",
  26. "Better Than Even",
  27. "Probably",
  28. "We Believe",
  29. "Likely",
  30. "Probable",
  31. "Very Good Chance",
  32. "Highly Likely",
  33. "Almost Certainly"))
  34. numberly$variable <- factor(numberly$variable,
  35. c("Hundreds of",
  36. "Scores of",
  37. "Dozens",
  38. "Many",
  39. "A lot",
  40. "Several",
  41. "Some",
  42. "A few",
  43. "A couple",
  44. "Fractions of"))
  45.  
  46. #Plot probability data
  47. png(file='~/Desktop/plot1.png', width = 800, height = 800)
  48. ggplot(probly,aes(variable,value))+
  49. geom_boxplot(aes(fill=variable),alpha=.5)+
  50. geom_jitter(aes(color=variable),size=4,alpha=.2)+
  51. coord_flip()+
  52. guides(fill=FALSE,color=FALSE)+
  53. xlab("Phrase")+
  54. ylab("Assigned Probability (%)")+
  55. z_theme()+
  56. scale_y_continuous(breaks=seq(0,100,10))+
  57. ggtitle("Perceptions of Probability")
  58. dev.off()
  59.  
  60. #Plot numberly data
  61. png(file='~/Desktop/plot2.png', width = 800, height = 500)
  62. ggplot(numberly,aes(variable,value))+
  63. geom_boxplot(aes(fill=variable),alpha=0.5)+
  64. geom_jitter(aes(color=variable),size=4,alpha=.2)+
  65. scale_y_log10(labels=trans_format("log10",math_format(10^.x)),
  66. breaks=c(.01,.1,1,10,100,1000,10000,100000))+
  67. guides(fill=FALSE,color=FALSE)+
  68. xlab("Phrase")+
  69. z_theme()+
  70. ylab("Assigned Number")+
  71. coord_flip()+
  72. ggtitle("Perceptions of Numbers")
  73. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement