Implementing my Twitter dashboard (i.e., finally getting to check off my more wistful to-do's)
As seems to be habit now, this post turned out a lot longer than I meant for it to. Quick links:
- Check out Joseph Stachelek's helpful tutorial to implement this yourself (trust me, despite the upcoming wall of text, I made very, very few actual changes to his original implementation, so you should just go straight there for the how-to)
- Check out my (now defunct) finished project here
Saving tweets for later: Hacky at best
When I come across a tweet containing information I would like future-me to take note of, I have a rather inelegant set of strategies for making sure it stays accessible (god forbid I merely rely on remembering; if it’s not down on an externally stored list somewhere outside my brain, it will never see the light of day again):
- Sometimes, I send the tweet as a direct message to myself (this acts as a bonus rush of dopamine, since Twitter somewhat cruelly sends me a notification when I do this, and for a split second I think I’m getting an exciting message from another human on Twitter…)
- Sometimes, if it’s something I’d like to try out myself at some point, I’ll add it to my Trello board. I have a special list for non-essential but fun tasks entitled “Wistful to dos when time allows (lolz)”. It’s nestled happily between my “Doing” and “Done” lists:
- Finally, sometimes I just like or retweet them. This used to be the least reliable way to assure that I’ll find them again because going back through old tweets is a pain…
Fortunately there is rtweet
, which virtually takes away all the pain associated with trying to find old tweets and scrolling through Twitter. I am still just getting the hang of it (see my previous post on using it to make wordclouds from conference hashtags), but am finding more and more ways to use it to my advantage, either for pure fun or organizational purposes.
Now, let’s be clear: I am far too Twitter-naïve and lazy to come up with useful implementations on my own, but luckily through the power of the interwebs other people are there for me and come up with genius hacks that I, too, can learn to do. One serendipitous case in point came by way of this tweet by Mara Averick, highlighting a tutorial written by Joseph Stachelek (see? two geniuses embedded in one tweet. So convenient for me to passively scroll by and click on.):
Use ❤️s as bookmarks? 👨 🍳 rtweet × DT ⇩
— Mara Averick (@dataandme) May 8, 2018
🐦 “Making a twitter dashboard with R” by @__jsta https://t.co/nPvkh4HhaK #rstats pic.twitter.com/DeOfCgLXQs
This sounded immediately appealing to me so, quickly and hackishly, I threw all of my don’t-forget-this-thing strategies at it: Liked it, RT’d it, DM’d myself it, and stuck it on my Trello board.
And there it has sat for the last 6 weeks, gathering metaphorical dust in only the ways forgotten corners of the internet can.
The “Wistful to do’s” section of my Trello board gets little love compared to the rest of it1. It has been quite a busy last couple of months, with wrapping up one study, getting another one off the ground, and completing a full-time clinical placement. So I’m not beating myself up on this at the moment. But today seemed a good day to tackle it. I had made sure to budget some time to work on fun stuff this weekend, so seemed like a good opportunity to sit on my air conditioned back porch and see if I could knock one or two things off that I’d been meaning to tackle2.
Twitter dashboard tutorial
👆 Joseph Stachelek’s tutorial is excellent and I really didn’t change much at all, so go right there and check it out if you want to implement something similar for yourself.
Things I did change:
The main thing I adapted was that I used my Twitter retweets instead of my likes. I realized while putting this together that I use the like feature fairly haphazardly, and curating a list of them is no more useful than trying to scroll back through my Twitter feed (for me, anyway; maybe others are more regimented in their doling out of hearts). It’s still not a perfect system (sometimes I retweet things that I want others to see, but I don’t necessarily need to refer back to it later - for example, R-Ladies #LdnOnt info), but that’s okay.
There’s no function in rtweet
(that I could find) that exclusively gets a user’s retweets, though it is simple to get all of a given user’s tweets (in this case, your own), and only include those that are either flagged as is_retweet==TRUE
or is_quote==TRUE
as in the following example. Here I also only selected the columns I was interested in. Namely I 1) excluded screen_name
, because it would always just be me in this case, and 2) included hashtags
, as I think this will ultimately be a useful variable to filter by, and 3) included retweet_text
. retweet_text
, it turns out, is important for the tweets that I just retweeted (and didn’t “quote”, or add my own comment to when retweeting). Turns out the text of a simple retweet will get truncated in the text
variable. In order to see the full original tweet (which undoubtedly was the important piece to begin with), you have to include retweet_text
. You could probably merge them together but I’m lazy and it is Good Enough for now.
Things that took me a little longer and outstanding to-do’s
- Figuring out how to turn it into a project on my website. Joseph’s tutorial handily includes how to use the
widgetframe
package to embed your dashboard on a website, but being the n00b I am it took me a bit to figure out how to put this on my own site. In retrospect that is because I tried the most obvious thing last: if you are using Blogdown and Hugo-Academic, just turn your script into an .Rmd file and store it in your content/projects folder. Tweak the YAML to include
output:
blogdown::html_page
and
image_preview: 'twitter_dashboard.png'
Making the text column wide enough, and the URL column narrower. I will not disclose how long I spent trying to tweak this and still not getting it to my liking. It’s perfectly spelled out in the tutorial how to increase the width of a given column, and all the stackexchange queries in the world support exactly what’s there. The size of my text column doesn’t seem to increase in the rendered version on my browser, though it did increase in my viewer, but it seems to ceiling out at a narrower width than I’d like (I failed to make it any wider than it currently is on the projects page). Annoyingly, I can’t seem to get the URL column to get any smaller, despite employing the same strategies. Surely there is an easy solution out there that Someone Else could figure out, but I am giving up for now. It’s Good Enough for today.
Merging text and retweet_text: I didn’t at first realize that regular retweets were getting truncated in the
text
variable. Once I figured out how to get the original text, I was happy, but ideally it’d be best to merge the two columns (e.g., whenretweet_text
is non-empty, replacetext
withretweet_text
). After a few feeble failed attempts at this I gave up. For another day.Updating it: There’s probably a way to make the dashboard update automatically, but as of right now it only seems to do so if I run the code again and update my site. Somewhat obnoxious, but that will be another wistful to do for later.
To Do ✅
I’ll probably still throw especially intriguing tutorials on my Trello board as a way to flag them, but I am very happy to now have a curated space to peruse the things I thought future-me would find useful. Saturday afternoon well spent, and a unicorn to-do finally moved over into Ryan Gosling’s very capable hands.
Perhaps that is a self-fulfilling prophecy, as I have captioned it with a unicorn and included a “lolz” mocking me in its title… note to self to revisit less self-defeating strategies at some point in the future…↩︎
- I’ll admit that part of my reasoning for tackling this today was due to the fact that 1) it was approximately eight bazillion degrees outside today, so hot that even my dog refused to spend much time with me outdoors, cutting our attempt at a run short, and 2) I spent an embarrasingly long and anxiety-inducing time scrolling through this Twitter thread last night and came to the conclusion that I have very little to contribute as of late:
↩︎You know what I'd like to hear more about, the lives of academics. No, not the juicy stuff, just, what ELSE do you do? Hobbies, pastimes. Surely, academia is not your WHOLE life (I hope). I want to feel “normal” for having hobbies, I guess. I never hear academics talk about that.
— Juneisy Quintana Hawkins (@JuneHawk20) June 29, 2018