| 1 |
\name{xy.unique.x} |
| 2 |
\alias{xy.unique.x} |
| 3 |
\title{Uniqify (X,Y) Values using Weights} |
| 4 |
\description{ |
| 5 |
Given \emph{smoother} data \eqn{(x_i, y_i)} and maybe weights \eqn{w_i}, |
| 6 |
with multiple \eqn{x_i}, use the unique x values, replacing the |
| 7 |
\eqn{y}'s by their (weighted) mean and updating the weights |
| 8 |
accordingly. |
| 9 |
} |
| 10 |
\usage{ |
| 11 |
xy.unique.x(x, y, w, fun.mean = mean, \dots) |
| 12 |
} |
| 13 |
\arguments{ |
| 14 |
\item{x,y}{numeric vectors of same length. Alternatively, \code{x} |
| 15 |
can be a \sQuote{xy} like structure, see \code{\link{xy.coords}}.} |
| 16 |
\item{w}{numeric vector of non-negative weights -- or missing which |
| 17 |
corresponds to all weights equal.} |
| 18 |
\item{fun.mean}{the mean \code{\link{function}} to use.} |
| 19 |
\item{\dots}{optional arguments all passed to \code{\link{unique}}.} |
| 20 |
} |
| 21 |
\value{ |
| 22 |
Numeric matrix with three columns, named |
| 23 |
\code{x}, \code{y} and \code{w} with unique \code{x} values and |
| 24 |
corresponding \code{y} and weights \code{w}. |
| 25 |
} |
| 26 |
\author{Martin Maechler, 8 Mar 1993.} |
| 27 |
\seealso{e.g., \code{\link{smooth.spline}} uses something like |
| 28 |
this internally.} |
| 29 |
\examples{ |
| 30 |
## simple example: |
| 31 |
x <- c(1,1,2,4,3,1) |
| 32 |
y <- 1:6 |
| 33 |
rbind(x, y) |
| 34 |
xy.unique.x(x, y) |
| 35 |
# x y w |
| 36 |
# 1 1 3 3 |
| 37 |
# 2 2 3 1 |
| 38 |
# 3 4 4 1 |
| 39 |
# 4 3 5 1 |
| 40 |
xy.unique.x(x, y, fromLast = TRUE) |
| 41 |
} |
| 42 |
\keyword{utilities} |