If your Twitter timeline is anything like mine, it’s a big mess. Various interests, jobs and acquaintancesor are mixed together. Frequent Posters get too much attention, as do the loud and random people that the Twitter algorithm thinks I’m interested in.
The result: My timeline bores me. Or the interesting stuff is too hidden.
Restart with a fresh timeline
My workflow to get a fresh timeline has two parts:
- Move all accounts I follow to a Twitter list. So I can muse in my old timeline if I want to.
- Unfollow all accounts, unless they are on a positive list
Workflow
I use the rtweet
package to use Twitter’s API from R.
At first, load the rtweet
package and connect to your Twitter account.
library(tidyverse)
library(rtweet)
# get access
get_token()
# Get all accounts I follow
accounts_I_follow_ids <- get_friends("you_twitter_handle") # your twitter user_name
accounts_I_follow_data <- lookup_users(accounts_I_follow_ids$user_id)
1. Move all accounts I follow to a Twitter list
I am somewhat of an archivist and I can’t bring myself to just delete them. So, I move them all in bulk to a fresh Twitter list.
# create a private list and add all accounts I follow
timeline_list <- post_list(
users = accounts_I_follow_data$screen_name,
name = "timeline-snapshot",
private = TRUE,
description = "All the accounts I follow February 2022")
Be aware, that there is a limit on how many accounts can be moved per day. If you want to move more than 1000 accounts you’ll get this message:
Warning: 104 - You aren't allowed to add members to this list.
This means: I have to wait 24 hours to load the next batch of users into the list.
Updating a list can be done like this:
timeline_list <- post_list(
users = accounts_I_follow_data$screen_name,
# get the list ID
# e.g. from list's URL
# or use rtweet::lists_memberships()
list_id = "numeric_list_id")
2. Unfollow all accounts, unless they are on a positive list
I created a csv
file that has one column called screen_name
and then I list all account names that I still want to follow.
# load your positive list
positive_list <- read.csv("positive_list.csv")
# generate a list of users to unfollow, expect when in positive list
accounts_to_unfollow <- accounts_I_follow_data %>%
filter(!screen_name %in% positive_list$screen_name)
# unfollow all, except the users on positive list
purrr::map(accounts_to_unfollow$user_id, function(i) {
post_unfollow_user(i)
})