Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Last year, I wrote a blog post discussing of how I found participating in #TidyTuesday every week for a year. Well, this year I did the same again. And so I’m writing another blog post about it! If you’re unfamiliar with #TidyTuesday, it’s a weekly data challenge aimed at the R community. Every week a new data set is posted alongside a chart or article related to that data set, and ask participants explore the data. You can access the data and find out more on GitHub.
So what have I learnt this year, that I didn’t know last year?
Recording the progress of making visualisations with {camcorder}: the {camcorder} R package records all of the plots you make on the way to making your final visualisation and turns them into a gif. It’s useful to showcase the process of how you make plots using {ggplot2}, and interesting to see how other people approach the making of plots!
Dealing with different resolutions when saving images: if you want to save high resolution images using ggsave()
this can sometimes lead to saved plots that look quite different compared to the preview in RStudio IDE. You can use {camcorder}, R Markdown, or Quarto to preview how your images look under higher resolutions – I also write a
blog post about this!
How R compares with Tableau for visualising data: to get a better idea of how Tableau compares with R for data visualisation, I started recreating some of my #TidyTuesday contributions using Tableau. Sometimes it was quicker to create visualisations in Tableau – the click-and-drag features make it easier to position elements exactly where you want them. However, the data wrangling capabilities of R make it a better option in my opinion! You can see my #TableauTuesday contributions on my Tableau Public profile.
A number of new R packages I hadn’t used before:
- {geomtextpath}: to create text which lies on curved paths
- {ggchicklet}: for creating bar charts with rounded edges
- {ggimage}: for using images in {ggplot2} graphics
- {showtext}: technically I did use this twice in 2021, but it’s become my go-to package for working with s!
- {ggtext}: allows you to use HTML or Markdown syntax for {ggplot2} text
- {ggforce}: provides additional geom and stat functions for use with {ggplot2}
- {poissoned}: implements the poisson disk sampling algorithm, which I used to create this plot…
And now it’s time for a recap of the year, where I show my:
- first visualisation of 2022,
- last visualisation of 2022,
- favourite visualisation of 2022,
- one I’d like to re-do visualisation of 2022!
My first visualisation of 2022 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
The first week of #TidyTuesday in 2022 was a “bring your own data” week! For this plot I tried out the aforementioned {geomtextpath} package to write some text in a spiral. The data behind this plot was the introduction to my recently completed PhD thesis. I quite liked this plot – the minimalist style was a theme I definitely leaned into this year!
My last visualisation of 2022 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
The last #TidyTuesday visualisation of 2022 (from today) looked at the titles in Star Trek: The Next Generation (Starfleet Academy) book series. I decided to keep this one visually simple, but there are two new things I tried in this visualisayion:
-
{eyedroppeR}: a colour palette generating package from Dan Oehm that allows you to select colours from images. I’d previously used imagecolorpicker.com for this purpose, but it’s great to bring this part of the design process inside R as well.
-
Justified text: support for justified (aligned to right and left margins) text in {ggplot2} isn’t built-in. Instead, you need to manually calculate varying text sizes – very much helped by this visualisation from Georgios Karamanis!
My favourite visualisation of 2022 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
Okay, so maybe this is cheating since it’s technically three visualisation… For this data set on psychometric scores of TV characters, I made radar plots showing the personality traits of different Killing Eve characters. I’m not generally a huge fan of radar plots, but for this week I was mostly focused on the design elements – which I think turned out really well! I focused on designing these plots to be viewed on mobile (since many of us spend too much time scrolling on our phones…) and tried to create character cards for three of the characters.
My one I’d like to re-do visualisation of 2022 < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
For this data set on Kaggle’s Hidden Gems, I looked at the sentiment analysis of notebook titles. The plot shows there’s no real change over time – which isn’t a very exciting finding. Part of the reason, I don’t like this plot so much is that it was created as an interactive HTML widget, which naturally doesn’t look so good as a static screenshot. I also don’t think the styling feels very neat, so I’d like to have another go at this one…
So that’s exactly what I did! In this re-worked version if the visualisation, I made two main changes:
- analysed the sentiments of the reviews, rather than the title,
- visualised the minimum and maximum sentiment of each volume, rather than the average.
You can download the code to create the re-worked version from my website.
Getting started with #TidyTuesday < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
If you’ve read this far, and you’re thinking about joining in with #TidyTuesday and haven’t already – I’d highly recommend it! Some useful resources for getting started:
-
The {ggplot2} book is freely available online and provides a useful reference for how different functions work.
-
The Graphic Design with ggplot2: How to Create Engaging and Complex Visualizations in R workshop materials from rstudio::conf(2022) by Cédric Scherer are available on GitHub.
Searching for #TidyTuesday on Twitter, LinkedIn, or Mastodon should also give some inspiration for what can be created in R!
Final thoughts < svg class="anchor-symbol" aria-hidden="true" height="26" width="26" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg"> < path d="M0 0h24v24H0z" fill="currentColor"> < path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76.0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71.0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71.0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76.0 5-2.24 5-5s-2.24-5-5-5z">
The code for all of my #TidyTuesday contributions is on GitHub, and you can view a curated selection of my favourite contributions on my portfolio page.
Huge thanks to R4DS team for putting #TidyTuesday together every week, and thanks to everyone who contributed data. I might add some data of my own next year…
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.