fix example function by adding negation 

`if(is.factor(grp))` should be `!if(is.factor(grp))` in order for the unit tests to work as described.