-
Notifications
You must be signed in to change notification settings - Fork 0
/
programing_1.R
55 lines (28 loc) · 942 Bytes
/
programing_1.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
load("./Senators_Data.Rdata")
install.packages("rtweet")
library(rtweet)
senators_data$twitter_url[1]
test <- get_timeline("https://twitter.com/SenDanSullivan")
gsub("https://twitter.com/", "", senators_data$twitter_url[1])
twitter_url_remover <- function(x)(
)
# criando uma função
twitter_url_remover <- function(x){
handle <- gsub("https://twitter.com/", "", x)
return(handle)
}
twitter_url_remover("https://twitter.com/SenDanSullivan")
tweet_holder <- as.data.frame(NULL)
for (i in 1:5) {
handle <- twitter_url_remover(senators_data$twitter_url[i])
tweets <- get_timeline(handle)
tweet_holder <- rbind(tweet_holder, tweets)
print(i)
}
senators_data$twitter_url[4]
tweet_holder$screen_name
# data merging
library(tidyverse)
tweet_holder$screen_name
senators_data$screen_name <- gsub("https://twitter.com/", "", senators_data$twitter_url)
merged_data <- left_join(tweet_holder, senators_data)