-
Notifications
You must be signed in to change notification settings - Fork 0
/
twittersample.R
27 lines (24 loc) · 1.17 KB
/
twittersample.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
install.packages("twitteR")
library(tidyverse)
library(twitteR)
library(openssl)
library(httpuv)
library(base64enc)
libray(readr)
setup_twitter_oauth( consumer_key="6WoyE8SKPd42xyX8cJA7PAAEo",
consumer_secret="vBeKwvD8AvsGlAvSUZyZSCuquuwBja7VowOg0KtNVLYGVptIsL",
access_token = "1327467001850322944-tv4VeJdEAnMPZ8YnhxKDWr5FDeUzyM",
access_secret = "4fp5a0ulTGF8Oc5EQR6rSCwkNEjzhiZS60iVHZC2O5FGg")
####new cases for 2020-11-01
graphic_covid <- read_csv("Data/graphic_covid.csv")
graphic_covid$date<- graphic_covid$date %>% as.character()
new_cases_for_tweet<- filter(graphic_covid, date=="2020-11-17")
new_cases_for_tweet<- new_cases_for_tweet %>% select(date, state, new_cases)
new_cases_for_tweet<- new_cases_for_tweet %>% group_by(state) %>% summarize(sum(new_cases))
new_cases_for_tweet$`sum(new_cases)`<- new_cases_for_tweet$`sum(new_cases)` %>%
as.character()
dailycases<-str_c(new_cases_for_tweet$`sum(new_cases)`, sep=",")
states<- str_c(new_cases_for_tweet$state, sep=",")
tweet<- str_c( states, dailycases, sep=":")
tweetfinal<- str_c(tweet, collapse=", ")
updateStatus(tweetfinal)