Following on from #555, it would be nice to extend this functionality to arbitrary summary statistics