Returns function(x) r8convert(x, type), which a type's package exports
under a name of its choice, such as as_granges(). The converter is also
the generic of the conversions to type: implement(as_target, Source) <- function(x) ... declares the conversion from the R8 type Source, and
implement(as_target, "character") <- function(x) ... the conversion from
a class, each an impl of From(source) for type.
Usage
r8converter(type)
# S3 method for class 'r8_converter'
print(x, ...)Value
r8converter(): A function of class r8_converter.
print(): x, invisibly.
Examples
op <- options(r8.namespace = "demo")
Pct <- new_struct("Pct2", fields = list(p = type_double(min = 0, max = 100)))
as_pct <- r8converter(Pct)
implement(as_pct, "numeric") <- function(x) Pct(p = x * 100)
as_pct(0.5)$p#> [1] 50as_pct#> <r8 converter demo::Pct2>
#> Methods for: numericoptions(op)