Convert various representations of a cell reference into an object of class cell_addr. Recall that cell_addr objects hold absolute row and column location, so ra_ref objects or cell reference strings with relative or mixed references will raise a warning and generate NAs.

as.cell_addr(x, ...)

as.cell_addr_v(x, ...)

# S3 method for class 'ra_ref'
as.cell_addr(x, ...)

# S3 method for class 'list'
as.cell_addr_v(x, ...)

# S3 method for class 'character'
as.cell_addr(x, fo = NULL, strict = TRUE, ...)

# S3 method for class 'character'
as.cell_addr_v(x, fo = NULL, strict = TRUE, ...)

Arguments

x

a cell reference

...

further arguments passed to or from other methods

fo

either "R1C1" (the default) or "A1" specifying the cell reference format; in many contexts, it can be inferred and is optional

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

a cell_addr object

Examples

as.cell_addr(ra_ref())
#> <cell_addr: 1 cells>
#> Warning: `as_data_frame()` was deprecated in tibble 2.0.0.
#>  Please use `as_tibble()` (with slightly different semantics) to convert to a
#>   tibble, or `as.data.frame()` to convert to a data frame.
#>  The deprecated feature was likely used in the cellranger package.
#>   Please report the issue at <https://github.com/rsheets/cellranger/issues>.
#> # A tibble: 1 × 2
#>     row   col
#>   <int> <int>
#> 1     1     1
#> 
rar <- ra_ref(2, TRUE, 5, TRUE)
as.cell_addr(rar)
#> <cell_addr: 1 cells>
#> # A tibble: 1 × 2
#>     row   col
#>   <int> <int>
#> 1     2     5
#> 
## mixed reference
rar <- ra_ref(2, FALSE, 5, TRUE)
as.cell_addr(rar)
#> Warning: Non-absolute references found ... NAs generated
#> <cell_addr: 1 cells>
#> # A tibble: 1 × 2
#>     row   col
#>   <int> <int>
#> 1    NA     5
#> 
ra_ref_list <-
  list(ra_ref(), ra_ref(2, TRUE, 5, TRUE), ra_ref(2, FALSE, 5, TRUE))
as.cell_addr_v(ra_ref_list)
#> Warning: Non-absolute references found ... NAs generated
#> <cell_addr: 3 cells>
#> # A tibble: 3 × 2
#>     row   col
#>   <int> <int>
#> 1     1     1
#> 2     2     5
#> 3    NA     5
#> 
as.cell_addr("$D$12")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.cell_addr("R4C3")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.cell_addr(c("$C$4", "$D$12"))
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.cell_addr("$F2")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.cell_addr("R[-4]C3")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.cell_addr("F2", strict = FALSE)
#> Error in loadNamespace(x): there is no package called ‘rematch’