| argvalsy.swap {fda} | R Documentation |
Preprocess argvals, y, and basisobj. If only one
of argvals and y is provided, use it as y and
take argvals as a vector spanning basisobj[['rangreval']]. If
both are provided, the simpler becomes argvals. If both have
the same dimensions but only one lies in basisobj[['rangreval']], that
becomes argvals.
argvalsy.swap(argvals=NULL, y=NULL, basisobj=NULL)
argvals |
a vector or array of argument values. |
y |
an array containing sampled values of curves. |
basisobj |
One of the following:
|
1. If y is NULL, replace by argvals.
2. If argvals is NULL, replace by
seq(basisobj[['rangeval']][1], basisobj[['rangeval']][2], dim(y)[1])
with a warning.
3. If the dimensions of argvals and y match and only
one is contained in basisobj[['rangeval']], use that as argvals
and the other as y.
4. if y has fewer dimensions than argvals, swap them.
a list with components argvals, y, and basisobj.
Data2fd
smooth.basis,
smooth.basisPar
##
## one argument: y
##
argvalsy.swap(1:5)
# warning ...
##
## (argvals, y), same dimensions: retain order
##
argy1 <- argvalsy.swap(seq(0, 1, .2), 1:6)
argy1a <- argvalsy.swap(1:6, seq(0, 1, .2))
all.equal(argy1[[1]], argy1a[[2]]) &&
all.equal(argy1[[2]], argy1a[[1]])
# TRUE; basisobj different
# lengths do not match
## Not run:
argvalsy.swap(1:4, 1:5)
## End(Not run)
##
## two numeric arguments, different dimensions: put simplest first
##
argy2 <- argvalsy.swap(seq(0, 1, .2), matrix(1:12, 6))
all.equal(argy2,
argvalsy.swap(matrix(1:12, 6), seq(0, 1, .2)) )
# TRUE with a warning ...
## Not run:
argvalsy.swap(seq(0, 1, .2), matrix(1:12, 2))
# ERROR: first dimension does not match
## End(Not run)
##
## one numeric, one basisobj
##
argy3 <- argvalsy.swap(1:6, b=4)
# warning: argvals assumed seq(0, 1, .2)
argy3. <- argvalsy.swap(1:6, b=create.bspline.basis(breaks=0:1))
# warning: argvals assumed seq(0, 1, .2)
argy3.6 <- argvalsy.swap(seq(0, 1, .2), b=create.bspline.basis(breaks=1:3))
# warning: argvals assumed seq(1, 3 length=6)
##
## two numeric, one basisobj: first matches basisobj
##
# OK
argy3a <- argvalsy.swap(1:6, seq(0, 1, .2),
create.bspline.basis(breaks=c(1, 4, 8)))
# Swap (argvals, y)
all.equal(argy3a,
argvalsy.swap(seq(0, 1, .2), 1:6,
create.bspline.basis(breaks=c(1, 4, 8))) )
# TRUE with a warning
## Not run:
# neither match basisobj: error
argvalsy.swap(seq(0, 1, .2), 1:6,
create.bspline.basis(breaks=1:3) )
## End(Not run)