R Functions by Matt Wand