rbase36

Convert an integer to base36


strtoi(x,base=36) will convert a base36-encoded string to an integer:

strtoi("zzzz",base=36)
[1] 1679615

Is there a function that inverts this operation, i.e., given a positive integer yields the base36 equivalent? Essentially, I'm looking for an itostr() function such that

itostr(1679615,base=36)
[1] "zzzz"

(I don't need any base other than 36, but a base argument would be nice to have.)


Solution

  • I believe if you install the package BBmisc, it has the itostr function is available.

    library(BBmisc)
    itostr(1679615,base=36)
    [1] "zzzz"