Created
November 8, 2017 02:55
-
-
Save juliasilge/0012543273062c6a7674a21eeed47f39 to your computer and use it in GitHub Desktop.
Check out whether downloading/tidying financial text data is working
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(tm.plugin.webmining) | |
library(tidyverse) | |
library(tidytext) | |
company <- c("Microsoft", "Apple", "Google", "Amazon", "Facebook", | |
"Twitter", "IBM", "Yahoo", "Netflix") | |
symbol <- c("MSFT", "AAPL", "GOOG", "AMZN", "FB", "TWTR", "IBM", "YHOO", "NFLX") | |
download_articles <- function(symbol) { | |
WebCorpus(GoogleFinanceSource(paste0("NASDAQ:", symbol))) | |
} | |
stock_articles <- data_frame(company = company, | |
symbol = symbol) %>% | |
mutate(corpus = map(symbol, download_articles)) | |
stock_tokens <- stock_articles %>% | |
unnest(map(corpus, tidy)) %>% | |
unnest_tokens(word, text) %>% | |
select(company, datetimestamp, word, id, heading) | |
stock_tokens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment