Skip to contents

Converts a defined vector to a base R numeric or character, retaining metadata as passive attributes.

Usage

strip_defined(x)

Arguments

x

A defined vector.

Value

A base R vector with attributes (label, unit, etc.) intact.

Examples

gdp <- defined(c(3897L, 7365L), label = "GDP", unit = "million dollars")
strip_defined(gdp)
#> [1] 3897 7365
#> attr(,"label")
#> [1] "GDP"
#> attr(,"unit")
#> [1] "million dollars"

fruits <- defined(c("apple", "avocado", "kiwi"),
  label = "Fruit", unit = "kg"
)

strip_defined(fruits)
#> [1] "apple"   "avocado" "kiwi"   
#> attr(,"label")
#> [1] "Fruit"
#> attr(,"unit")
#> [1] "kg"