Learn R Programming

hyper2 (version 3.0-0)

character_to_number: 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))

Author

Robin K. S. Hankin

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().

See Also

rank_likelihood

Examples

Run this code
 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))



Run the code above in your browser using DataLab