character_to_number: Convert a character vector to a numeric vector

Description Usage Arguments Details Author(s) See Also Examples

Description

Convert string descriptions of competitors into their number

Usage

1
2

Arguments

char

Character vector to be converted

pnames

Names vector (usually pnames(H))

Details

The internal mechanism of functions such as ggol(), and all the C++ code, operates 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.

Author(s)

Robin K. S. Hankin

See Also

order_likelihood

Examples

1
2
3
4
5
6
7
8
H <- hyper2(pnames=letters[1:9])

# Use numbers:
H + order_likelihood(sample(9))  


# Use letters:
H + order_likelihood(character_to_number(sample(letters[1:9]),pnames(H)))

hyper2 documentation built on July 6, 2017, 9:02 a.m.