character_to_number: Convert a character vector to a numeric vector

character_to_numberR Documentation

Convert a character vector to a numeric vector

Description

Convert string descriptions of competitors into their number

Usage

character_to_number(char, pnames)
char2num(char, pnames)

Arguments

char

Character vector to be converted

pnames

Names vector (usually pnames(H))

Details

In earlier versions of this package, the internal mechanism of functions such as ggrl(), and all the C++ code, operated with the competitors labelled with a non-negative integer; it is then natural to refer to the competitors as p1, p2, etc.

However, sometimes the competitors have names (as in, for example, the rowing dataset). If so, it is more natural to refer to the competitors using their names rather than an arbitrary integer.

Function character_to_number() converts the names to numbers. If an element of char is not present in pnames, an error is returned (function char2num() is an easy-to-type synonym). The function is here because it is used in ggrl().

Author(s)

Robin K. S. Hankin

See Also

rank_likelihood

Examples

 x <- sample(9)
 names(x) <- sample(letters[1:9])
 H <- rank_likelihood(x)
 character_to_number(letters[1:3],pnames(H))

 char2num(c("PB","L"),pnames(icons))




hyper2 documentation built on June 22, 2024, 9:57 a.m.