scripts/twitter_twitteR.R

library(twitteR)
library(base64enc)
library(tidyverse)
library(lubridate)
library(dplyr)
library(readr)

## Anneke ##
consumer_key <- "xTsioaHOTvLlMEx0tMc43aSGS"
consumer_secret <- "Rx2xUiR1Np2s4ULC2aNC9FoheJIUz9j3E3T7os2Y3Mflv6fl5o"
access_token <- "48829073-zxXCU1412QQy7ezGZxJeDoQFN7BafeyI89jecbPu6"
access_secret <- "IcrUwqHifivKw3jclwH5A7WpNfPyN9f9EmtlQtuxQXaBF"
twitteR::setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
## Soren ##
consumer_key <- "xOqmpoGBMr91X2iKAgJey8ehn"
consumer_secret <- "GgDPJIQWGsXxgNxs262LIAwIPB3qXO0OgTg4Rgl1yyjtZEYC7J"
access_token <- "1049665959663947777-KWBBLprqiC1EL0HYWXH4RCpVwOY13S"
access_secret <- "I3SE6GrD4fEgCweW3L2Q3Rh5QjEgeRpTSTtdB9RT7HjoC"
twitteR::setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)


searchTerm = "bitcoin+btc"
tw = twitteR::searchTwitter(searchTerm, n = 1e2, since = '2016-11-08',
                            until = "2018-09-31",
                            retryOnRateLimit = 1e3)
tw_tbl <- twitteR::twListToDF(tw) %>%
  tibble::as_tibble()

readr::write_csv(tw_tbl, path = "/Users/anneke/Dropbox/master/Data/Twitter/twit_data_",
                 lubridate::today(),"_with_20181001.csv")

# twit_1e5 <- readr::read_csv("C:/Users/Soren Schwartz/Dropbox/Egne dokumenter/Skole/master/Data2018-10-11")
xts::periodicity(twit_1e5$created)
# tw %>%
#   twitteR::twListToDF() %>%
#   tibble::as_tibble() %>%
#   dplyr::pull(created) %>%
#   xts::periodicity()
range(twit_1e5$created)[1] %>%
  lubridate::as_date() %>%
  as.character()
3schwartz/SpecialeScrAndFun documentation built on May 4, 2019, 6:29 a.m.