Created
October 7, 2019 15:55
-
-
Save monogenea/7f9b5c77aced21dbc7253dd6ea1f33a8 to your computer and use it in GitHub Desktop.
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
# Wed May 8 21:22:45 2019 ------------------------------ | |
# Use status_id to identify and exclude duplicates | |
library(rtweet) | |
# List all files | |
allFiles <- paste0("tweets/", list.files("tweets/")) | |
# Write function to merge tweets | |
mergeTweets <- function(recipient, donor){ | |
idx <- !donor$status_id %in% recipient$status_id | |
return(do_call_rbind(list(recipient, donor[idx, ]))) | |
} | |
for(i in allFiles){ | |
if(i == allFiles[1]){ | |
allTweets <- read_twitter_csv(file = i, | |
unflatten = T) | |
}else{ | |
tmp <- read_twitter_csv(file = i, | |
unflatten = T) | |
allTweets <- mergeTweets(allTweets, tmp) | |
} | |
} | |
# Write CSV | |
write_as_csv(allTweets, file_name = "gotTwitter.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment