How to do calculated columns with user defined functions?

I posted a better example here: Calling user defined function to calculate column values - General - RStudio Community