# 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