3 How We Extracted Data
3.1 How We Extracted Twitter Data
Below is the code we used to search for tweets using our developer account and token. Each day, we collected data for Dell, Microsoft, Cisco, and Amazon. We organized the names of each day’s data by date to streamline our referencing process. To reduce repetition, we removed retweets from our collected data. We also set the daily number of tweets retrieved to 10,000 (n= 10000) to ensure sure all usable data was collected.
dell_tweets7.20 <- search_tweets(
q='@DellCares',
n= 10000,
include_rts = FALSE,
lang= "en",
geocode = lookup_coords("usa"),
retryonratelimit = FALSE)
## Downloading [>----------------------------------------] 2%
## Downloading [>----------------------------------------] 3% Downloading
## [=>---------------------------------------] 4%
3.2 How We Extracted Stock Data
In this chunk of code, we utilized the ‘quantmod’ library to retrieve stock data for Microsoft, Amazon, and Dell for the past 21 days (starting on June 30th). Once this data is pulled from Yahoo Finance, we can see the end-of-day stock price for each company, and combine them into one condensed table, later to be visualized.
getSymbols(c("CSCO", "MSFT", "AMZN", "DELL"), # CSCO = Cisco, MSFT = Microsoft, AMZN = Amazon, DELL = Dell
src = 'yahoo',
from = (Sys.Date() - 22),
to = Sys.Date())
## [1] "CSCO" "MSFT" "AMZN" "DELL"