Learn R Programming

ThomasJeffersonUniv (version 0.1.3)

hexavigesimalExcel: Hexavigesimal (Base 26L) and Excel Columns

Description

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

Usage

Excel2int(x)

Excel2C(x)

Value

Function Excel2int returns an integer

vector.

Function Excel2C returns a character

vector.

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.

Decimal012526275152676702703
Hexavigesimal; C01P10111P20100110111
Hexavigesimal; Excel0AYZAAAYAZYZZZAAA

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.

References

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

See Also

Examples

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

Run the code above in your browser using DataLab