letterToNumber: Convert letters to numbers as on a telephone's keypad

Description Usage Arguments Value Examples

View source: R/letterToNumber.R

Description

Take a character vector and convert it to the equivalent number sequence from a telephone's key pad

Usage

1
letterToNumber(value, qz = 1)

Arguments

value

An input value as a character vector with one element (a string)

qz

Whether to assign q and z to zero (qz = 0) or not (any other value)

Value

A character vector of numbers and dashes based on value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Convert an alphabetic string can be converted directly (with
# non-alphanumeric characters replaced by dashes)

letterToNumber("R functions") # returns "7-386284667"

# Of course, vectors containing strings can also be converted

string <- "Phone Number"
letterToNumber(string) # returns "74663-686237"

# Alphanumeric strings can also be converted with numbers being returned as
# is

letterToNumber("Jenny's number is 867-5309") # returns "53669-7-686237-47-867-5309"

# Specifying qz = 0 maps "q" and "z" to 0 instead of 7 and 9

letterToNumber("qz") # returns "79"
letterToNumber("qz", qz = 0) # returns ("00")

scumdogsteev/phonenumber documentation built on May 8, 2021, 1:17 a.m.