::install_github('tingtingzhan/hexExcel') remotes
Excel-Style Hexavigesimal (A to Z)
Introduction
This vignette of package hexExcel
(Github, RPubs) documents …
Prerequisite
New features are first implemented on Github.
Note to Users
Examples in this vignette require that the search
path has
library(hexExcel)
Conversion Table
Convert between decimal integer
, C-style hexavigesimal 0-9, A-P
, and Excel-style hexavigesimal A-Z
.
= c(NA_integer_, 1L, 9L, 10L, 25L, 26L, 27L, 51L, 52L, 676L, 702L, 703L)
int = int |> int2Excel() hex_Excel
R code: to create this table
c(
'Hexavigesimal, Excel-Style', hex_Excel |> sprintf(fmt = '`%s`'),
'Hexavigesimal, C-Style', hex_Excel |> Excel2C() |> toupper() |> sprintf(fmt = '`%s`')
|>
) matrix(ncol = 2L, dimnames = list(c('Decimal `integer` to Hexavigesimal', as.character(int)), NULL)) |>
t.default() |>
as.data.frame.matrix() |>
::kable() knitr
Decimal integer to Hexavigesimal |
NA | 1 | 9 | 10 | 25 | 26 | 27 | 51 | 52 | 676 | 702 | 703 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Hexavigesimal, Excel-Style | NA |
A |
I |
J |
Y |
Z |
AA |
AY |
AZ |
YZ |
ZZ |
AAA |
Hexavigesimal, C-Style | NA |
1 |
9 |
A |
P |
10 |
11 |
1P |
20 |
100 |
110 |
111 |
Excel2C()
Function Excel2C()
converts Excel-style hexavigesimal A-Z
to C-style hexavigesimal 0-9, A-P
.
|>
hex_Excel Excel2C()
# [1] NA "1" "9" "a" "p" "10" "11" "1p" "20" "100" "110" "111"
Excel2int()
Function Excel2int()
converts Excel-style hexavigesimal A-Z
to decimal integer
, using function Excel2C()
and base::strtoi()
.
|>
hex_Excel Excel2int()
# [1] NA 1 9 10 25 26 27 51 52 676 702 703
int2Excel()
Function int2Excel()
converts decimal integer
to Excel-style hexavigesimal A-Z
.
|>
int int2Excel()
# [1] NA "A" "I" "J" "Y" "Z" "AA" "AY" "AZ" "YZ" "ZZ" "AAA"
Function int2Excel()
works very differently from R’s solution to hexadecimal and decimal conversions. Function base::as.hexmode()
returns an object of typeof
integer
. Then, function base::format.hexmode()
, i.e., the workhorse of function base::print.hexmode()
, relies on the %x
(hexadecimal) format option of function base::sprintf()
.
Appendix
Terms & Abbreviations
Term / Abbreviation | Description |
---|---|
|> |
Forward pipe operator introduced since R 4.1.0 |
$ |
Extract parts of an object |
CRAN, R | The Comprehensive R Archive Network |
class |
Object class |
hexadecimal, as.hexmode |
Base-16 number system |
hexavigesimal | Base-26 number system, in C-style |
S3 , generic , methods |
S3 object oriented system, UseMethod ; getS3method ; https://adv-r.hadley.nz/s3.html |
S4 , generic , methods |
S4 object oriented system, isS4 ; setClass ; getMethod ; https://adv-r.hadley.nz/s4.html |
search |
Search path |