hexavigesimalExcel {ThomasJeffersonUniv}R Documentation

Hexavigesimal (Base 26L) and Excel Columns

Description

Convert between decimal, hexavigesimal in C-style, and hexavigesimal in Excel-style.

Usage

Excel2int(x)

Excel2C(x)

Arguments

x

character scalar or vector, which consists of (except missingness) only letters A to Z and a to z.

Details

Convert between decimal, hexavigesimal in C-style, and hexavigesimal in Excel-style.

Decimal 0 1 25 26 27 51 52 676 702 703
Hexavigesimal; C 0 1 P 10 11 ⁠1P⁠ 20 100 110 111
Hexavigesimal; Excel 0 A Y Z AA AY AZ YZ ZZ AAA

Function Excel2C converts from hexavigesimal in Excel-style to hexavigesimal in C-style.

Function Excel2int converts from hexavigesimal in Excel-style to decimal, using function Excel2C and strtoi.

Value

Function Excel2int returns an integer vector.

Function Excel2C returns a character vector.

References

http://mathworld.wolfram.com/Hexavigesimal.html

See Also

as.hexmode

Examples

int1 = c(NA_integer_, 1L, 25L, 26L, 27L, 51L, 52L, 676L, 702L, 703L)
Excel1 = c(NA_character_, 'A', 'Y', 'Z', 'AA', 'AY', 'AZ', 'YZ', 'ZZ', 'AAA')
C1 = c(NA_character_, '1', 'P', '10', '11', '1P', '20', '100', '110', '111')
stopifnot(identical(int1, Excel2int(Excel1)), identical(int1, strtoi(C1, base = 26L)))

int2 = c(NA_integer_, 1L, 4L, 19L, 37L, 104L, 678L)
Excel2 = c(NA_character_, 'a', 'D', 's', 'aK', 'cZ', 'Zb')
stopifnot(identical(int2, Excel2int(Excel2)))
Excel2C(Excel2)

head(swiss[Excel2int('A')])

[Package ThomasJeffersonUniv version 0.1.3 Index]