Skip to contents

Translates from excel cell address to rows and columns

Usage

cell_range_translate(x, expand = TRUE, start = "A1")

Arguments

x

Single string of individual cell or cell range (e.g. "D6" or "D6:AC8")

expand

If TRUE (default), provides the row and column for all cells in the range. If False, provides just the row and column of the start and end cells.

start

Optional argument to account for offset when matching cells in an excel file to a dataframe when the dataframe was generated by reading the excel file starting at a location other than "A1".

Value

dataframe of addresses for each cell in the range, where $row gives the row number and $col gives the column number.

Examples

cell_range_translate("D6")
#>   row col
#> 1   6   4
cell_range_translate("A2:H3")
#>    row col
#> 1    2   1
#> 2    3   1
#> 3    2   2
#> 4    3   2
#> 5    2   3
#> 6    3   3
#> 7    2   4
#> 8    3   4
#> 9    2   5
#> 10   3   5
#> 11   2   6
#> 12   3   6
#> 13   2   7
#> 14   3   7
#> 15   2   8
#> 16   3   8