Quick recap: to use the functions above, load your archive manifest with read_archive_json() and then pass it to read_twitter_data() along with an item name from the archive. simplify_twitter_data purrr :: map(names) |> purrr :: reduce(union) if ( length(item_names) > 1) return(x) x |> purrr :: map(item_names) |> purrr :: map_dfr(simplifier) } ) read_archive_json(fileName)) } #' Simplify the data, if possible and easy #' #' x A list of lists as returned from `read_twitter_data()` #' simplifier A function that's applied to each item in the #' list of lists and that can be used to simplify the output data. #' Read the Twitter Archive JSON #' #' path Path to a Twitter archve `.js` file read_archive_json purrr :: transpose() |> purrr :: pmap(\(fileName. Let’s start by assuming this file is JSON and reading it in. The data/ folder also contains a manifest.js file that can be used to help read the data included in the archive. accountDisplayName: The account’s name as displayed on the profile. createdAt: Date and time when the account was created. accountId: Unique identifier for the account. username: The account’s current Note that the may change but the account ID will remain the same for the lifetime of the account. For example: “web” if the account was created from a browser. createdVia: Client application used when the account was created. email: Email address currently associated with the account if an email address has been provided. Here’s how the README describes the account.js data file: account.js First, the README.txt file explains the structure and layout of the files, and includes descriptions of the data contained in all of the files. The data/ folder is surprisingly well structured! There are two key files to help you find your way around the archive. The rtweet package is excellent for this, even though it takes a little effort to get it set up. I’m also going to have some fun with ggiraph for turning static ggplot2 plots into interactive plots.įinally, the Twitter archive doesn’t require API access to Twitter, but you can use it to augment the data in the archive. To read in the data files, I’ll use jsonlite to read the archive JSON data, with a small assist from brio for fast file reading. (I’m using the dev version of tidyverse (1.), which loads lubridate automatically, and the dev version of purrr that is slated to become version 1.0.0.) On the R side, we’ll need the usual suspects: tidyverse and glue. I’ve copied that data/ directory into my working directory for this post. But the real archive lives in the included data/ folder as a bunch of. The archive downloads as a zip file containing a standalone web page - called Your archive.html - for exploring your data. Make sure you download it before Nov 12, 2022, 9:46:31 PM Your Twitter archive is ready for you to download and view using your desktop browser. After you submit the request, it takes about a day or so for an email to show up in your your Twitter data is ready If you don’t have it yet, go to Settings and Privacy and click Download an archive of your data. Reading your Twitter archive Get your Twitter data archiveįirst things first, you need to have your Twitter data archive. I’ve also included a section on using rtweet to collect a full dataset about the tweets you’ve liked and another section about the advertising data in your Twitter archive. The second half of the post showcases a collection of plots about monthy tweet volume, popular tweets, the time of day when tweets were sent, and the app used to send the tweet. Read on to learn how to read your Twitter archive into R, or how to tidy your tweets. This post, very much inspired by the awesome Observable notebook, Planning to leave Twitter?, shows you how to use R to read and explore your archive, using my own archive as an example. Not only does the archive include all of your tweets, it also contains a variety of other interesting data about your account: who you followed and who followed you the tweets you liked the ads you were served and much more. Whether or not you’re considering jumping ship to another service - you can find me lurking on Mastdon - you should download an archive of your Twitter data. Twitter finds itself in an… interesting… transition period.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |