Initial version

I had posted an earlier version of this function to R-Help in July, 2011.