sort.freqlist {mclm}R Documentation

Sort a frequency list

Description

This method sorts an object of class freqlist.

Usage

## S3 method for class 'freqlist'
sort(
  x,
  decreasing = FALSE,
  sort_crit = c("ranks", "names", "orig_ranks", "freqs"),
  na_last = TRUE,
  ...
)

Arguments

x

Object of class freqlist.

decreasing

Logical. If TRUE items are sorted from large to small; if FALSE, from small to large.

Note, however, that ranking in frequency lists is such that lower ranks correspond to higher frequencies. Therefore, sorting by rank (either "ranks" or "orig_ranks") with decreasing set to its default value FALSE results in the highest frequencies ending up at the beginning of the sorted list.

sort_crit

Character string determining the sorting criterion.

If sort_crit is "ranks", then the items in the frequency list are sorted by their current frequency rank.

If sort_crit is "names", then the items in the frequency list are sorted alphabetically their name.

If sort_crit is "orig_ranks", then the items in the frequency list are sorted by their original ranks (if those are present), or by their current frequency ranks (if no original ranks are present).

Finally, sorting with sort_crit set to "freqs" is identical to sorting by frequency ranks, but with the meaning of the argument decreasing being reversed. In other words, sorting by frequencies ("freqs") with decreasing set to its default value FALSE results in the lowest frequencies ending up at the beginning of the sorted list.

na_last

Logical defining the behavior of NA elements.

This argument is only relevant when sort_crit is "orig_ranks" because currently names and frequencies are not allowed to be NA in frequency lists.

If na_last is TRUE, then items with a sorting criterion of NA end up at the end of the sorted frequency list. If na_last is FALSE, then items with a sorting criterion of NA end up at the start of the sorted frequency list. If na_last is NA, then items with a sorting criterion of NA are removed from the sorted frequency list.

...

Additional arguments.

Details

Because of the way ranks are calculated for ties (with lower ranks being assigned to ties earlier in the list), sorting the list may affect the ranks of ties. More specifically, ranks among ties may differ depending on the criterion that is used to sort the frequency list.

Value

Object of class freqlist.

Examples

(flist <- freqlist(tokenize("the old story of the old man and the sea.")))
sort(flist)
sort(flist, decreasing = TRUE)

[Package mclm version 0.2.7 Index]