From http://stackoverflow.com/questions/22198951/calculate-mean-with-a-filter-on-a-columns-values

Applying functions on a filtered column