Skip to contents

Returns a plain R vector representation of x, for which is.vector() is TRUE: an atomic vector for scalar-backed classes, or a named list of coerced properties for compound classes.

Usage

as_vector(x, ...)

Arguments

x

Any. Object to coerce.

...

Additional arguments passed to methods.

Value

An atomic vector or a named list.

Examples

library(S7)
#> 
#> Attaching package: ‘S7’
#> The following objects are masked from ‘package:s7x’:
#> 
#>     class_double, class_integer
Point <- new_class(
  "Point",
  properties = list(x = class_double, y = class_double)
)
as_vector(Point(1, 2))
#> $x
#> [1] 1
#> 
#> $y
#> [1] 2
#>