Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

letter-num-conversion

Convert between letter and integer representations of column IDs


Description

Convert "A1"-style column IDs from a letter representation to an integer, e.g. column A becomes 1, column D becomes 4, etc. Or go the other way around.

Usage

letter_to_num(x)

num_to_letter(y)

Arguments

x

a character vector of "A1" style column IDs (case insensitive)

y

a vector of integer column IDs

Details

  • Google Sheets have up to 300 columns (column KN).

  • Excel 2010 spreadsheets have up to 16,384 columns (column XFD).

  • ZZ is column 702.

  • ZZZ is column 18,278 (no known spreadsheet actually goes that high).

Value

a vector of column IDs, either character or integer

Examples

letter_to_num('Z')
letter_to_num(c('AA', 'ZZ', 'ABD', 'ZZZ'))
letter_to_num(c(NA, ''))
num_to_letter(28)
num_to_letter(900)
num_to_letter(18278)
num_to_letter(c(25, 52, 900, 18278))
num_to_letter(c(NA, 0, 4.8, -4))

cellranger

Translate Spreadsheet Cell Ranges to Rows and Columns

v1.1.0
MIT + file LICENSE
Authors
Jennifer Bryan [cre, aut], Hadley Wickham [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.