Blog

4 novembre 2019 · R · data.table

Switching to data.table with Zwift

the cousin of pandas is a morse.

Article en anglais.

Tom Simpson / Mont Ventoux, 13th July 1967

After having used the tidyverse toolkit for a while to wrangle data in R, i recently switched to the data.table package. I found this page very helpful to grasp the power of data.table.

For dataset bigger than 1GB than can fit into the RAM, read, write, filter and aggregations operations are 10 to 100 times faster than the dplyr/base R tools.

On top of that, i found its syntax extremely concise, like writing Haiku in R. I started learning R using the dplyr/tidyr packages three years ago, and switching to data.table is a logical evolution.

As a Zwift player, i explored their API with the help of data.table.

Zwift players overview

Using logged in players data scrapped from the Zwift API between 17th to 25th October, we can have a look at how does the Zwifter population looks like.

Total players per country: US far ahead, then GB, DE and Zwift's own ZW accounts
Share of women players per country (countries with more than 2000 players), from about 19% in Canada down to under 5% in Italy
New registered players per week, women and men, 2015 to 2019: winter peaks every year and a sharp spike in autumn 2019
Age distribution of players by gender, with median ages around 39 for women and 41 for men
Median age per country (countries with more than 2000 players), from 46 in the US down to 32 in China
Median weight in kg per age class and country, men
Median weight in kg per age class and country, women
Total players versus total population per country, log scales (population source: World Bank 2016)

Final thought:

Using the activity data, i tried to figure out whether the evolution over the time of the average Watts (per ride duration) was somehow related to other features but could not come to any significant relationships.