martharotter/twitter-sentiment-irish-presidential-election
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
INTRODUCTION
This project contains all the code necessary to reproduce the analysis
of Irish Presidential candidate sentiment via Twitter. This project is
a fork of Jeffrey Breen's wonderful tutorial & slides at:
http://jeffreybreen.wordpress.com/2011/07/04/twitter-text-mining-r-slides/
CONTENTS
data/
opinion-lexicon-English/ - Hu & Liu's opinion lexicon
negative-words.txt
NLP-handbook-sentiment-analysis.pdf
positive-words.txt
source.txt
source.webloc
output/ - output files, mainly graphics
twitter_score_histograms.pdf
R/ - R source code
0_start.R
1_loadAras.R
2_runAras.R
scrapeAras.R
sentiment.R
LICENSE - Copyright per Apache 2.0 license
README - this file
INSTRUCTIONS
In order to run the analysis, start R from this project's root directory
or it with setwd()
1. Load the prerequisite packages, our score.sentiment() function, and
some environment variables with the "0_start.R" script:
> source("R/0_start.R")
2. This distribution does not ship with any data from Twitter, so you will need
to collect your own the first time you attempt to run this package.
To collect data from Twitter, simply execute the "scrapeAras.R" script:
> source("R/scrapeAras.R")
This script caches your collected tweets to the data/ directory, so you
only need to run this step once.
3. Load the Twitter data and opinion lexicon from disk:
> source("R/1_loadAras.R")
If this is your first time running this code, and you have not followed Step 2
to collect your own Twitter data, you will see this error message:
Error: Tweets not found on disk -- source('R/scrapeAras.R') to scrape Twitter first
4. Run the analysis:
> source("R/2_runAras.R")
Progress messages will be displayed on the console and all generated graphics will
be displayed and saved as PDFs in the output/ directory.
Martha Rotter
martha@martharotter.com
October 2011