1 Content
This workshop is split into four parts:
- Part 1 - Introduction to R
- how to load data into R
- how to conduct basic descriptive statistics
- how to use
ggplot
to make basic plots
- Part 2 - Collecting Twitter data
- how to collect data and search for tweets by content, user, and location
- how to analyse word frequency on Twitter (including ngrams, and changes in frequency over time)
- Part 3 - Working with geocoded Tweets
- how to work with geolocation data and visualise regional variation
- how to plot static and interactive maps
- Part 4 - Sentiment analysis
- how to perform sentiment analysis
- how to compare the evaluation of topics discussed on Twitter
2 Structure of materials
The four parts of this workshop can be accessed via the navigation menu at the top of each page.
Throughout these materials, the R code will appear in chunks. In all cases, the output of each chunk of code will also appear below. For example:
## [1] 22
When referring to R packages, functions, or the names of objects loaded into the workspace, they will appear in this font
.
Overview
Each section contains an initial overview…
Exercise
… and sets of exercises to work on independently (while I come round and solve any coding problems!)
3 Setting a working directory
How you organise your files is up to you, but there are certainly good ways and bad ways of doing it. I would recommend writing your code into separate scripts for each part of the workshop, and saving all of these into the same folder - call it something sensible like twitter_workshop
. I also recommend making a sub-folder inside this called data
, where you can save all the datasets we’ll be working with:
twitter_workshop
| part1_script.R
| part2_script.R
| part3_script.R
| part4_script.R
| data
| tweets_1.Rdata
| tweets_2.Rdata
You’ll also want to set this folder as your working directory in R - basically this means that R will look in this folder by default when you’re saving/loading things. For example, I would set my working directory to:
This means that if I want to load one of the datafiles we’ll need for the workshop, I can just say:
Instead of:
You can always check what your current working directory is set to by running:
If you want to set your working directory but you’re not sure of the full file path to the twitter_workshop
folder you just created, there’s an even easier way of setting it in R. Once you’ve saved your empty script into the folder, you can click at the top of the screen on Session → Set Working Directory → To Source File Location