as_fr_field {fr}R Documentation

Coerce character, factor, numeric, logical, and Date vectors into fr_field objects

Description

The supported classes of R objects are converted to the corresponding frictionless type:

R class fr type
character() string
factor() string (with enum(constraints = levels(x)))
numeric(), integer() number
logical() boolean
Date date

Usage

as_fr_field(x, ...)

Arguments

x

a character, factor, numeric, integer, logical, or Date vector

...

<dynamic-dots> required (name) and optional (title, description) field descriptors)

Value

a fr_field object

Examples

as_fr_field(1:10, "example_integer") # -> frictionless number
as_fr_field((1:10) * 0.1, "example_double") # -> frictionless number
as_fr_field(letters, "example_character") # -> frictionless string
as_fr_field(factor(letters), "example_factor") # -> frictionless string with enum constraints
as_fr_field(c(TRUE, FALSE, TRUE), "example_logical") # -> frictionless boolean
as_fr_field(as.Date(c("2023-04-23", "2004-12-31")), "example_date") # -> frictionless date

[Package fr version 0.5.1 Index]