These functions are the extensions that allow tf
vectors
to work with vctrs
.
Usage
# S3 method for tfd_reg
vec_cast(x, to, ...)
# S3 method for tfd_irreg
vec_cast(x, to, ...)
# S3 method for tfd_reg
vec_cast.tfd_reg(x, to, ...)
# S3 method for tfd_irreg
vec_cast.tfd_reg(x, to, ...)
# S3 method for tfb_spline
vec_cast.tfd_reg(x, to, ...)
# S3 method for tfb_fpc
vec_cast.tfd_reg(x, to, ...)
# S3 method for tfd_reg
vec_cast.tfd_irreg(x, to, ...)
# S3 method for tfd_irreg
vec_cast.tfd_irreg(x, to, ...)
# S3 method for tfb_spline
vec_cast.tfd_irreg(x, to, ...)
# S3 method for tfb_fpc
vec_cast.tfd_irreg(x, to, ...)
# S3 method for tfb_spline
vec_cast(x, to, ...)
# S3 method for tfb_fpc
vec_cast(x, to, ...)
# S3 method for tfb_spline
vec_cast.tfb_spline(x, to, ...)
# S3 method for tfb_fpc
vec_cast.tfb_spline(x, to, ...)
# S3 method for tfb_spline
vec_cast.tfb_fpc(x, to, ...)
# S3 method for tfb_fpc
vec_cast.tfb_fpc(x, to, ...)
# S3 method for tfd_reg
vec_cast.tfb_spline(x, to, ...)
# S3 method for tfd_irreg
vec_cast.tfb_spline(x, to, ...)
# S3 method for tfd_reg
vec_cast.tfb_fpc(x, to, ...)
# S3 method for tfd_irreg
vec_cast.tfb_fpc(x, to, ...)
# S3 method for tfd_reg
vec_ptype2(x, y, ...)
# S3 method for tfd_reg
vec_ptype2.tfd_reg(x, y, ...)
# S3 method for tfd_irreg
vec_ptype2.tfd_reg(x, y, ...)
# S3 method for tfb_spline
vec_ptype2.tfd_reg(x, y, ...)
# S3 method for tfb_fpc
vec_ptype2.tfd_reg(x, y, ...)
# S3 method for tfd_irreg
vec_ptype2(x, y, ...)
# S3 method for tfd_reg
vec_ptype2.tfd_irreg(x, y, ...)
# S3 method for tfd_irreg
vec_ptype2.tfd_irreg(x, y, ...)
# S3 method for tfb_spline
vec_ptype2.tfd_irreg(x, y, ...)
# S3 method for tfb_fpc
vec_ptype2.tfd_irreg(x, y, ...)
# S3 method for tfb_spline
vec_ptype2(x, y, ...)
# S3 method for tfb_spline
vec_ptype2.tfb_spline(x, y, ...)
# S3 method for tfb_fpc
vec_ptype2.tfb_spline(x, y, ...)
# S3 method for tfd_reg
vec_ptype2.tfb_spline(x, y, ...)
# S3 method for tfd_irreg
vec_ptype2.tfb_spline(x, y, ...)
# S3 method for tfb_fpc
vec_ptype2(x, y, ...)
# S3 method for tfb_spline
vec_ptype2.tfb_fpc(x, y, ...)
# S3 method for tfb_fpc
vec_ptype2.tfb_fpc(x, y, ...)
# S3 method for tfd_reg
vec_ptype2.tfb_fpc(x, y, ...)
# S3 method for tfd_irreg
vec_ptype2.tfb_fpc(x, y, ...)
Arguments
- x
Vectors to cast.
- to
Type to cast to. If
NULL
,x
will be returned as is.- ...
For
vec_cast_common()
, vectors to cast. Forvec_cast()
,vec_cast_default()
, andvec_restore()
, these dots are only for future extensions and should be empty.- y
Vectors to cast.
Details
Notes on vec_cast
:
Use tf_rebase()
to change the representations of tf
-vectors,
these methods are only for internal use --
automatic/implicit casting of tf
objects is tricky
because it's hard to determine automatically whether such an operation would
lose precision (different bases with different expressivity? different
argument grids?), and it's not generally clear which instances of which
tf
-subclasses should be considered the "richer" objects.
Rules for casting:
If the casted object's
domain
would not contain the entire originaldomain
, no casting is possible (would lose data).Every cast that evaluates (basis) functions on different
arg
values is a lossy cast, since it might lose precision (vctrs::maybe_lossy_cast
).As long as the casted object's
domain
contains the entire originaldomain
:every
tfd_reg
,tfd_irreg
ortfb
can always be cast into an equivalenttfd_irreg
(which may also change itsevaluator
anddomain
).every
tfd_reg
can always be cast totfd_reg
(which may change itsevaluator
anddomain
)every
tfb
can be cast losslessly totfd
(regular or irregular, note it's lossless only on the originalarg
-grid)
Any cast of a
tfd
intotfb
is potentially lossy (because we don't know how expressive the chosen basis is)Only
tfb
with identical bases and domains can be cast into one another losslessly