Skip to content

Instantly share code, notes, and snippets.

View rheimann's full-sized avatar

Rich Heimann rheimann

View GitHub Profile
@rheimann
rheimann / sentimentRAW
Created November 18, 2013 01:30
sentimentRAW
## 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",
@rheimann
rheimann / recessionboxplots
Created November 18, 2013 00:59
recessionboxplots R
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
@rheimann
rheimann / recessionbars
Created November 18, 2013 00:58
recession bars R
rect2001 <- data.frame (
xmin=2001, xmax=2002, ymin=-Inf, ymax=Inf)
rect2007 <- data.frame (
xmin=2007, xmax=2009, ymin=-Inf, ymax=Inf)
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)