Improve frequencies method

Now allow frequencies to be passed a function.
The resulting dictionary will be the frequency of results when applying
the function.