Added a subroutine to calculate frequencies of nominal data.