Introducing a New Course on Mapping Geographic Data in R, with ggplot2

I’m happy to announce a new course on mapping geographic data in R, using the ggplot2 package. The course is by data journalist and visualization consultant Maarten Lambrechts, and it’s available immediately to FlowingData members.

If you’re not a member yet, now is a great time to join. You get instant access to this course, plus four others and over a hundred in-depth visualization tutorials.

For those who’ve read FlowingData for a while probably know that I’m not much of ggplot2 user. It’s not that I don’t like it. I just never worked it into my workflow, and what I’m using now hasn’t stalled my work yet.

But when it comes to visualizing data, I’m a firm believer in learning a wide array of tools. A flexible toolset lets you visualize data in the way that you want. The tool shouldn’t be the limiting factor.

Hence, this course.

I worked through the course myself, and I’ll tell you first-hand that it’s fun, practical, and will get you up to speed quick. There’s real data, concrete examples, and you’ll be making beautiful maps with your own data in no time.

Check it out now.

Tags: , ,

R graphics get modern text support, with ragg package

Thomas Lin Pedersen announced the ragg package, which makes font usage in R more straightforward:

I’m extremely pleased to present the culmination of several years of work spanning the systemfonts, textshaping, and ragg packages. These releases complete our efforts to create a high-quality, performant raster graphics device that works the same way on every operating system.

This blog post presents our improvements to ragg’s font rendering so that it now “just works” regardless of what you throw at it. This includes:

  1. Support for non-Latin scripts including Right-to-Left (RtL) scripts
  2. Support for OpenType features such as ligatures, glyph substitutions, etc.
  3. Support for color fonts
  4. Support for font fallback

All of the above comes in addition to the fact that ragg is able to use all of your installed fonts.

If you’ve tried to make publication-level graphics completely in R, you’re probably familiar with the challenge of using non-default fonts. The correct steps depend on your system and the words you want to add. It’s one of the reasons I bring R output into Adobe Illustrator, so now there’s one less extra step. Nice.

Tags: , ,

Parsing a table from an image

Thomas Mock explains how to extract and parse data tables in image files via ImageMagick and R:

There are many times where someone shares data as an image, whether intentionally due to software constraints (ie Twitter) or as a result of not understanding the implications (image inside a PDF or in a Word Doc). xkcd.com jokingly refers to this as .norm or as the Normal File Format. While it’s far from ideal or a real file format, it’s all too common to see data as images in the “wild”. I’ll be using some examples from Twitter images and extracting the raw data from these. There are multiple levels of difficulty, namely that screenshots on Twitter are not uniform, often of relatively low quality (ie DPI), and contain additional “decoration” like colors or grid-lines. We’ll do our best to make it work!

You can never have too many tools to grab data from various, inconvenient file formats.

Tags: , , , , ,

Turn images into LEGO builds in R

The brickr package in R by Ryan Timpe takes an image, converts it to a mosaic, and then provides a piece list and instructions for the build. While not officially affiliated with the LEGO group, Timpe is a data scientist for LEGO, so it’s probably as close as you’re going to get to real deal.

Timpe made a package a couple of years back, but when I went to use it, the link was broken and I assumed it was defunct. This is a nice surprise.

My kids are deep into LEGO these days. We just finished watching the LEGO Masters show. I have LEGO minifigures on my office wall. I’m definitely making use of this.

Tags: , , ,

Making map art in R

If you can make maps in your software and customize the aesthetics, you can make map art. Esteban Moro outlined how he made a personalized map in R:

For my map art, I wanted to create something more personal: a combination of those beautiful street maps with personal mobility. That is, the city and how we navigate it. In this tutorial, you’ll learn how to create those street maps for your city and your mobility. We will use data from Open Street Maps (OSM) and, of course, R. We will also use personal mobility data, which you can input manually. Still, we will learn too how to get it from Google Maps Timeline (if you have your location activated). Part of the material here is based on the tutorial by Christian Burkhart.

Tags: ,

Presidential Plinko

To visualize uncertainty in election forecasts, Matthew Kay from Northwestern University used a Plinko metaphor. The height of each board is based on the distribution of the forecast, and each ball drop is a potential outcome. The animation plays to eventually shows a full distribution.

See it in action.

(And Kay made his R code available on GitHub.)

Tags: , , , ,

Friends sitcom transcript dataset

For your analytical perusal, Emil Hvitfeldt provides ten seasons’ worth of scripts from the Friends sitcom in an easy-to-use R package:

The goal of friends to provide the complete script transcription of the Friends sitcom. The data originates from the Character Mining repository which includes references to scientific explorations using this data. This package simply provides the data in tibble format instead of json files.

The ten seasons ran from 1994 to 2004. I’m suddenly feeling my age.

Tags: ,

Using a slime mold simulation for generative art

Slime mold are single-celled organisms that can work together to form multicellular structures. Antonio Sánchez Chinchón used slime mold simulations generate these images:

This post talks about a generative system called Physarum model, which simulates the evolution of a colony of extremely simple organisms that, under certain environmental conditions, result into complex behaviors. Apart from the scientific interest of the topic, this model produce impressive images like this one, that I call The Death of a Red Dwarf

You can check out the code, a combination of R and C++, on GitHub.

Tags: , , ,

R turned 20 years old

R turned 20 last week. The first public release of R was on February 29, 2000. Jozef Hajnala with the look back:

The power of R comes by no small part from the fact that it is easily extensible and the extensions are easily accessible using The Comprehensive R Archive Network, known to most simply as CRAN.

My initial reaction was, “Wow, 20 years. R is old.” And then I realized, “So R was only… three when I started using it… wait a minute.”

Tags: ,

Posted by in birthday, R, software

Tags: ,

Permalink

Scripts from The Office, the dataset

The decade is almost done. You’re sitting there and you’re thinking: “I wish I could easily access the scripts from all seasons of The Office so that I could analyze the dialogue and relationships between characters.” Well, your wish is granted. Bradley Lindblad stuck all the scripts in an R package. It’s called schrute.

Take that, 2019.

Tags: , ,