xyw.coords {DierckxSpline} | R Documentation |
Extract arguments, eliminate duplicates in x, averaging corresponding y's, summing corresponding weights, and maintaining the dominant sign of convexity constraints.
xyw.coords(x, y = NULL, w = NULL, v = NULL, ...)
x |
A data.frame , matrix , or numeric
vector. See details. |
y |
Optional numeric vector. See details. |
w |
Optional vector of weights |
v |
Convexity constraints. See details. |
... |
Optional arguments, currently ignored. |
'x' and 'y' are first passed to xy.coords
for
initial parsing. Then duplicate 'x' values are identified, and
corresponding values of y, w and v are processed to average y's, sum
w's, and use sign(sum(v's)). If(missing(w)) w = 1. If(missing(v)) v
= 0.
A list with the following components:
x |
unique of input x values, sorted |
y |
input y, arranged to match x, with values corresponding to duplicate x values replaced by their mean. |
w |
input w, arranged to match x, with values corresponding to duplicate x values replaced by their sum. |
v |
input v, arranged to match x, with values corresponding to duplicate x values replaced by the sign of their sum. |
xin |
input x values |
yin |
input y values |
Sundar Dorai-Raj
Dierckx, P. (1991) Curve and Surface Fitting with Splines, Oxford Science Publications.
x <- c(3, 1, 3+1e-7, 6, 3+5e-7, 5) y <- c(3, 1, 2, 6, 4, 5) tst <- xyw.coords(x, y) ans <- list(x = c(1, 3+2e-7, 5:6), y = c(1, 3, 5:6), w = c(1, 3, 1, 1), v = rep(0, 4), xin=x, yin=y) all.equal(tst, ans) # TRUE #all.equal(tst$x, c(1, 3, 5:6)) #[1] "Mean relative difference: 6.666666e-08"