Adds nil check in lua avg method.
Merge pull request #220 from matthelm/fix-avg-aggregate

Adds nil check in lua avg method.