R – Convert a decimal into an alphabetic column id


Working with some spreadsheet stuff, internally the columns are referred to by a simple decimal number (0 indexed), but for the output, I need it to be in the standard human readable format:

A, B, C, .. Z, AA, AB, AC, .. AZ, BA ..

I first thought "easy! I'll just switch to base 26 and use [A-Z] instead of [0-9A-P]", except that using this technique makes A => 0. B => 1. Therefore the sequence actually goes like this:

A, B, .. Y, Z, BA, BB

How do you convert decimals to an excel-style column name?

Related Question