ranks {mclm}R Documentation

Retrieve the current ranks for frequency counts.

Description

ranks retrieves from the ranks of its items in an object. These ranks are integer values running from one up to the number of items in x. Each items receives a unique rank. Items are first ranked by frequency in descending order. Items with identical frequency are further ranked by alphabetic order.

Usage

ranks(x, ...)

## S3 method for class 'freqlist'
ranks(x, with_names = FALSE, ...)

Arguments

x

An object of any of the classes for which the method is implemented.

...

Additional arguments.

with_names

Logical. Whether or not the items in the output should be given names. If TRUE, then the names of the types in the frequency list are used as names.

Details

The mclm method ranks() is not to be confused with base::rank(). There are two important differences.

First,base::rank() always ranks items from low values to high values and ranks() ranks from high frequency items to low frequency items.

Second, base::rank() allows the user to choose among a number of different ways to handle ties. In contrast, ranks() always handles ties in the same way. More specifically, items with identical frequencies are always ranked in alphabetical order.

In other words, base::rank() is a flexible tool that supports a number of different ranking methods that are commonly used in statistics. In contrast, ranks() is a rigid tool that supports only one type of ranking, which is a type of ranking that is atypical from a statistics point of view, but is commonly used in linguistic frequency lists. Also, it is designed to be unaffected by the order of the items in the frequency list.

Value

Numeric vector representing the current ranks, with as its names the types to which the ranks apply.

See Also

Other getters and setters: n_tokens(), n_types(), orig_ranks(), tot_n_tokens(), type_names()

Examples

(flist <- freqlist("The man and the mouse.", as_text = TRUE))

orig_ranks(flist)
ranks(flist)
ranks(flist, with_names = TRUE)

(flist2 <- keep_types(flist, c("man", "and")))

orig_ranks(flist2)
ranks(flist2)

[Package mclm version 0.2.7 Index]