This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## LOAD LEXICONS & SENTIMENT FUNCTIONS ## | |
# load sentiment function. The https_function loads the R file directly into our session. Alternately | |
# you can go the https://github.com/SocialMediaMininginR and download the sentiment_function. | |
https_function("https://raw.github.com/rheimann/sentiment_function/master/sentiment.R") | |
# Source: http://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html & http://www3.nd.edu/~mcdonald/Word_Lists.html | |
# download positive lexicons from SocialMediaMining Github account | |
download.file("https://raw.github.com/SocialMediaMininginR/pos_words/master/positive-words.txt", | |
destfile = "/Users/heimannrichard/Google Drive/SocialMediaMiningR/twitter_sentiment/data/pos_words.txt", method = "curl") | |
download.file("https://raw.github.com/SocialMediaMininginR/pos_words/master/LoughranMcDonald_pos.csv", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BB.boxplot <- ggplot(BB.sentiment, aes(x=BB.sentiment$year, y=BB.sentiment$centered, group=BB.sentiment$year)) | |
BB.boxplot <- BB.boxplot + geom_boxplot(outlier.colour = "black", outlier.shape = 16, outlier.size = 2) | |
BB.boxplot <- BB.boxplot + geom_rect(data=rect2001, aes(xmin=xmin, xmax=xmax, ymin=-Inf, ymax=+Inf), fill='pink', alpha=0.2, inherit.aes = FALSE) | |
BB.boxplot <- BB.boxplot + geom_rect(data=rect2007, aes(xmin=xmin, xmax=xmax, ymin=-Inf, ymax=+Inf), fill='pink', alpha=0.2, inherit.aes = FALSE) | |
BB.boxplot <- BB.boxplot + xlab("Year") + ylab("Sentiment (Centered)") + ggtitle("Economic Sentiment - Beige Book (1996-2010)") | |
BB.boxplot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rect2001 <- data.frame ( | |
xmin=2001, xmax=2002, ymin=-Inf, ymax=Inf) | |
rect2007 <- data.frame ( | |
xmin=2007, xmax=2009, ymin=-Inf, ymax=Inf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
ggplot(Twitter, aes(x=regiontxt, y=flecMC, ylab="Flesch Kincaid Index", xlab="Region", data=Twitter)) | |
geom_point(colour="lightblue", alpha=0.1, position="jitter") + | |
geom_boxplot(outlier.size=1, alpha=0.1) | |
boxplot(flecMC~regiontxt, ylab="flecMC", xlab="regiontxt", data=Twitter) |