A1_to_R1C1: Convert cell reference strings from A1 to R1C1 format

Description Usage Arguments Value Examples

Description

Convert cell reference strings from A1 to R1C1 format. Strictly speaking, this only makes sense for absolute references, such as "$B$4". Why? Because otherwise, we'd have to know the host cell of the reference. Set strict = FALSE to relax and treat pure relative references, like ("B4"), as if they are absolute. Mixed references, like ("B$4"), will always return NA, no matter the value of strict.

Usage

1
A1_to_R1C1(x, strict = TRUE)

Arguments

x

character vector of cell references in A1 format

strict

logical, affects reading and writing of A1 formatted cell references. When strict = TRUE, references must be declared absolute through the use of dollar signs, e.g., $A$1, for parsing. When making a string, strict = TRUE requests dollar signs for absolute reference. When strict = FALSE, pure relative reference strings will be interpreted as absolute, i.e. A1 and $A$1 are treated the same. When making a string, strict = FALSE will cause dollars signs to be omitted in the reference string.

Value

character vector of absolute cell references in R1C1 format

Examples

1
2
3
4
5
A1_to_R1C1("$A$1")
A1_to_R1C1("A1")                 ## raises a warning, returns NA
A1_to_R1C1("A1", strict = FALSE) ## unless strict = FALSE
A1_to_R1C1(c("A1", "B$4")) ## raises a warning, includes an NA, because
A1_to_R1C1(c("A1", "B$4"), strict = FALSE) ## mixed ref always returns NA

Example output

[1] "R1C1"
[1] NA
Warning message:
Mixed or relative cell references found ... NAs generated 
[1] "R1C1"
[1] NA NA
Warning message:
Mixed or relative cell references found ... NAs generated 
[1] "R1C1" NA    
Warning message:
Mixed or relative cell references found ... NAs generated 

cellranger documentation built on May 2, 2019, 11:26 a.m.