Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Import files, load plot and data packages, fire up the number machine.
- probly <- read.csv("~/Desktop/probly.csv", stringsAsFactors=FALSE)
- numberly <- read.csv("~/Desktop/numberly.csv", stringsAsFactors=FALSE)
- library(ggplot2)
- library(reshape2)
- library(scales)
- library(RColorBrewer)
- #Melt data into column format.
- numberly <- melt(numberly)
- numberly$variable <- gsub("[.]"," ",numberly$variable)
- probly <- melt(probly)
- probly$variable <- gsub("[.]"," ",probly$variable)
- #Order in the court!
- probly$variable <- factor(probly$variable,
- c("Chances Are Slight",
- "Highly Unlikely",
- "Almost No Chance",
- "Little Chance",
- "Probably Not",
- "Unlikely",
- "Improbable",
- "We Doubt",
- "About Even",
- "Better Than Even",
- "Probably",
- "We Believe",
- "Likely",
- "Probable",
- "Very Good Chance",
- "Highly Likely",
- "Almost Certainly"))
- numberly$variable <- factor(numberly$variable,
- c("Hundreds of",
- "Scores of",
- "Dozens",
- "Many",
- "A lot",
- "Several",
- "Some",
- "A few",
- "A couple",
- "Fractions of"))
- #Plot probability data
- png(file='~/Desktop/plot1.png', width = 800, height = 800)
- ggplot(probly,aes(variable,value))+
- geom_boxplot(aes(fill=variable),alpha=.5)+
- geom_jitter(aes(color=variable),size=4,alpha=.2)+
- coord_flip()+
- guides(fill=FALSE,color=FALSE)+
- xlab("Phrase")+
- ylab("Assigned Probability (%)")+
- z_theme()+
- scale_y_continuous(breaks=seq(0,100,10))+
- ggtitle("Perceptions of Probability")
- dev.off()
- #Plot numberly data
- png(file='~/Desktop/plot2.png', width = 800, height = 500)
- ggplot(numberly,aes(variable,value))+
- geom_boxplot(aes(fill=variable),alpha=0.5)+
- geom_jitter(aes(color=variable),size=4,alpha=.2)+
- scale_y_log10(labels=trans_format("log10",math_format(10^.x)),
- breaks=c(.01,.1,1,10,100,1000,10000,100000))+
- guides(fill=FALSE,color=FALSE)+
- xlab("Phrase")+
- z_theme()+
- ylab("Assigned Number")+
- coord_flip()+
- ggtitle("Perceptions of Numbers")
- dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement