Learn R Programming

qqid (version 1.0.3)

qMap: qMap

Description

qMap maps numbers to Q-words, or Q-words to their index in (0, 1023).

Usage

qMap(x)

Arguments

x

(character or numeric) A vector.

Value

(numeric or character) A vector of indices, Q-words, or NA of the same length as the input.

Description

qMap accepts strings that are matched to Q-word indices or NA, or numbers that are matched to Q-words or NA. The returned vector has the same length as the input. Numbers that are not in (0, 1023) return NA. Strings that are not a Q-word return NA. qMap(0) is "aims", qMap(1023) is "zone". Note: the first Q-word has index 0, since it represents the bit-pattern "0000000000".

Q-Words

A table of 1,024 four-letter words is encoded in this function. Four-letter English words were chosen and manually refined to yield short, unique labels that:

  • are monosyllabic,

  • are easy to spell and pronounce,

  • are individually not offensive,

  • are unlikely to be offensive in random combination,

  • are in common use,

  • avoid homophones and consonant clusters,

  • do not contain jargon, intentional misspellings, acronyms or overly specialized technical or sports terms.

The table is alphabetically sorted.

Examples

Run this code
# NOT RUN {
# qMap a number
qMap(313)                                    # "gift"
# qMap four words, three can be matched.
qMap(c("three", "free", "cold", "beer"))     # NA 287  125  34
# return the entire QQ table
x <- qMap(0:1023)

# }

Run the code above in your browser using DataLab