Turns an ordinary R object into a valid input for a struct type and
constructs the value: it removes names and other attributes from scalar
and vector fields, converts a character vector to a factor with declared
levels, POSIXlt to POSIXct, a tibble or data.table to a data.frame,
resets row names, expands an Rle, constructs a nested struct from a
named list, and drops members that are not fields. It reports each change
in one message. Construction itself stays strict: a value r8conform()
cannot make valid raises the same errors as the type's constructor.
Examples
op <- options(r8.namespace = "demo")
Weights <- new_struct("Weights", fields = list(w = vec(type_double(min = 0))))
q <- stats::quantile(c(1, 2, 3))
x <- r8conform(list(w = q), Weights)#> r8conform() made 1 change(s) for `demo::Weights`:
#> /w: removed the attributes namesoptions(op)