Last active
January 5, 2024 20:54
-
-
Save mermelstein/5e843cb75aca221249732c6a79997dad to your computer and use it in GitHub Desktop.
twitter data to df
This file contains hidden or 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
library(jsonlite) | |
library(brio) | |
# where is the archive directory | |
dir_path <- "~/Downloads/twitter-archive/data" | |
# file in /data with the tweets | |
filename <- "tweets.js" | |
# get full file path | |
js_file_path <- file.path(dir_path, filename) | |
f <- brio::read_file(js_file_path) | |
data <- jsonlite::fromJSON(substr(f, 27, nchar(f)), flatten = TRUE) | |
data <- as.data.frame(data) | |
# check out tweets | |
head(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment