Data Challenges for R Users

by Isabella Velásquez

Today, I want to write about “data challenges”, where participants partake in a series of prompts designed for a variety of skill sets and levels. These challenges are opportunities to practice programming skills, work on algorithmic efficiency, or learn something new. Often, participants share the code for their submissions, teaching others their processes and techniques.

The challenges test the participants’ tenacity with time-bound but flexible prompts. TidyTuesday was originally borne out of the R4DS Online Learning Community and the R for Data Science textbook. RStudio’s Tom Mock shares a dataset every Tuesday. The challenge is to explore the dataset and create a chart within seven days. Participants decide what variables to focus on and how to best visualize them.

Using a recent TidyTuesday dataset, Moriah Taylor visualizes alternative fueling stations in the U.S. The stacked tilted maps communicate relationships, density, and location while demonstrating beautiful design.

Stacked tilted map showing density of biodiesel, propane, ethanol, and electric fueling stations in the U.S.

Moriah’s code introduced me to the layer package, which tilts maps and turns them into ggplot2 objects:

#plot tilted maps
plot <- plot_tiltedmaps(maps_list,
                layer = c("value", "value", "value", "value"),
                palette = c("magma", "magma", "magma", "magma"))

Data challenges can also be language-agnostic. Genuary encourages participants to create works of generative art with the programming language of their choice. R users apply their coding skills and tools in imaginative ways. On Day 6 of genuary, Ryan Timpe “destroys the square”:

Generative art of nine squares with pieces missing or torn

Taking a look at the code, we learn how to plot a square in R with the tidyr and dplyr packages:

library(tidyverse)
set.seed(12238)

#The square

square_size = 400

the_square <- expand_grid(
  x=1:square_size,
  y=1:square_size
) %>%
  mutate(
    color = "#87ceeb"
  )

plot(the_square$x, the_square$y)

We can also see how Ryan inserts randomness to ‘destroy’ the square through the strategic use of functions like sample() and runif():

circ_origin_size = square_size * runif(1, 2/4, 3/4)

Interested in participating in a data challenge? The 30 Day Chart Challenge is coming up. The organizers offer different chart types for you to visualize in April. Showcase your R skills, test your perseverance, and use the hashtag #30DayChartChallenge to share your work with other participants.

We started to compile a list of other data challenges to join. Please leave a comment if you are aware of others.

Timeframe Name URL
January genuary http://genuary.art/
April 30 Day Chart Challenge https://twitter.com/30DayChartChall
October Hacktoberfest https://hacktoberfest.digitalocean.com/
November 30 Day Map Challenge https://github.com/tjukanovt/30DayMapChallenge
December Advent of Code https://adventofcode.com/
Monday Makeover Monday https://www.makeovermonday.co.uk/
Tuesday Tidy Tuesday https://github.com/rfordatascience/tidytuesday
Thursday, Summer Months Recreation Thursday https://github.com/sharlagelfand/RecreationThursday
Sunday SportsViz Sundays https://data.world/sportsvizsunday
Monthly SWD https://community.storytellingwithdata.com/
Ongoing 100 Days of Code https://www.100daysofcode.com/

Thank you to Moriah Taylor and Ryan Timpe for sharing their visualizations.

Share Comments · · · ·

You may leave a comment below or discuss the post in the forum community.rstudio.com.