xy.unique.x {sfsmisc} | R Documentation |
Given smoother data (x_i, y_i) and maybe weights w_i, with multiple x_i, use the unique x values, replacing the y's by their (weighted) mean and updating the weights accordingly.
xy.unique.x(x, y, w, fun.mean = mean)
x,y |
numeric vectors of same length. Alternatively, |
w |
numeric vector of non-negative weights – or missing which corresponds to all weights equal. |
fun.mean |
the mean function to use. |
Numeric matrix with three columns, named
x
, y
and w
with unique x
values and
corresponding y
and weights w
.
Martin Maechler, 8 Mar 1993.
e.g., smooth.spline
uses something like
this internally.
## simple example: xy.unique.x(c(1,1,1,2,4), 1:5) # x y w # 1 1 2 3 # 2 2 4 1 # 3 4 5 1