Posts

Introduction The tidycat package includes the tidy_categorical() function to expand broom::tidy() outputs for categorical parameter estimates. Documentation For full documentation, see the package vignette: The tidycat package: expand broom::tidy() output for categorical parameter estimates Hello World The tidy() function in the broom package takes the messy output of built-in functions in R, such as lm(), and turns them into tidy data frames. library(dplyr) library(broom) m1 <- mtcars %>% mutate(transmission = recode_factor(am, `0` = "automatic", `1` = "manual")) %>% lm(mpg ~ transmission + wt * as.

CONTINUE READING

Over the last year or so I have been playing around with different ways of showing changing global bilateral migrant stocks, adapting the animation code I created for the plots for region to region flows in this estimation paper. I am putting them online here in case they are of interest to anyone else. The first plot below shows the change over time in the pattern of global migrant stocks.

CONTINUE READING

We have had a number of requests for the R code to replicate the plots in our paper on internal migration in China. The code below will produce a similar looking plot, but I have taken out some of the arguments that were very specific to our plot that will not replicate well for other data. Data The code is based on two data sets: Bilateral flow data with three columns only (origin, destination and flow), see here for the file used below Region details used for plotting, see here for the file used below Note, the names in the region data are the same as the ones used in the origin and destination data.

CONTINUE READING

During the last few months I have given some introductory talks on international migration in Asia and Europe. I had a couple of requests to share the animated chord diagrams that I created for others to use in their teaching materials. These are below, along with some extra plots for Africa, the Americas (Northern, Central and Southern America as well as the Caribbean) and Oceania. The chords in the diagrams represent the connection between the places of birth (at the base of the chord) and places of residence (at the arrow head of the chord).

CONTINUE READING

Background I’m loving the magick package at the moment. Reading through the vignette I spotted the image_morph() function. In this post I experiment with the function to build the GIF below that shows the changes in the England football first kit over time, using images from the excellent Historical Football Kits website. Scraping The Historical Football Kits website has a detailed section on England kits spread over six pages, starting from the first outfits used in 1872.

CONTINUE READING

Background A little while ago my paper in International Migration Review on global migration flow estimates came out online. The paper includes a number of directional chord diagrams to visualize the estimates. Recently I have been playing around tweenr and the magick packages for animated population pyramids. In this post I attempt to show how to use these packages to produce animated directional chord diagrams of global migration flow estimates

CONTINUE READING