Convert various representations of a cell reference into an object of class
ra_ref.
as.ra_ref is NOT vectorized and therefore requires the input to
represent exactly one cell, i.e. be of length 1.
as.ra_ref_v accepts input of length >= 1 and returns a list of
ra_ref objects.
as.ra_ref(x, ...)
as.ra_ref_v(x, ...)
# S3 method for class 'character'
as.ra_ref(x, fo = NULL, strict = TRUE, ...)
# S3 method for class 'character'
as.ra_ref_v(x, fo = NULL, strict = TRUE, ...)
# S3 method for class 'cell_addr'
as.ra_ref(x, ...)
# S3 method for class 'cell_addr'
as.ra_ref_v(x, ...)one or more cell references, as a character vector or
cell_addr object
further arguments passed to or from other methods
either "R1C1" (the default) or "A1" specifying the
cell reference format; in many contexts, it can be inferred and is optional
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.
a ra_ref object, in the case of as.ra_ref, or a
list of them, in the case of as.ra_ref_v
## as.ra_ref.character()
as.ra_ref("$F$2")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.ra_ref("R[-4]C3")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.ra_ref("B4")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.ra_ref("B4", strict = FALSE)
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.ra_ref("B$4")
#> Error in loadNamespace(x): there is no package called ‘rematch’
## this is actually ambiguous! is format A1 or R1C1 format?
as.ra_ref("RC2")
#> Error in loadNamespace(x): there is no package called ‘rematch’
## format could be specified in this case
as.ra_ref("RC2", fo = "R1C1")
#> Error in loadNamespace(x): there is no package called ‘rematch’
as.ra_ref("RC2", fo = "A1", strict = FALSE)
#> Error in loadNamespace(x): there is no package called ‘rematch’
## as.ra_ref_v.character()
cs <- c("$A$1", "Sheet1!$F$14", "Sheet2!B$4", "D9")
if (FALSE) { # \dontrun{
## won't work because as.ra_ref requires length one input
as.ra_ref(cs)
} # }
## use as.ra_ref_v instead
as.ra_ref_v(cs, strict = FALSE)
#> Error in loadNamespace(x): there is no package called ‘rematch’
## as.ra_ref.cell_addr
ca <- cell_addr(2, 5)
as.ra_ref(ca)
#> <ra_ref>
#> row: 2 (abs)
#> col: 5 (abs)
#> R2C5
## as.ra_ref_v.cell_addr()
ca <- cell_addr(1:3, 1)
if (FALSE) { # \dontrun{
## won't work because as.ra_ref methods not natively vectorized
as.ra_ref(ca)
} # }
## use as.ra_ref_v instead
as.ra_ref_v(ca)
#> [[1]]
#> <ra_ref>
#> row: 1 (abs)
#> col: 1 (abs)
#> R1C1
#>
#> [[2]]
#> <ra_ref>
#> row: 2 (abs)
#> col: 1 (abs)
#> R2C1
#>
#> [[3]]
#> <ra_ref>
#> row: 3 (abs)
#> col: 1 (abs)
#> R3C1
#>