locapply | R Documentation |
locapply
applies given function to portions of y
in the local x
neighbourhood. This generalizes e.g. lowess
as you can compute any function of y
, not only the mean.
locapply(x, y, fun, bandwidth = 0.2,
...)
x |
vector of x-coordinates |
y |
vector of y-coordinates |
fun |
function to be applied; it will be passed a vector of |
bandwidth |
|
... |
additional arguments to |
A list of vectors x
and y
holding the x-coordinates,
and the result of fun
applied to the local neighbourhood
of corresponding element of x
.
Tomas Sieger
set.seed(1)
n<-100
x<-sort(runif(n,0,5))
y<-runif(n,-exp(x),exp(x))
plot(x,y,pch=19)
lines(x,locapply(x,y,quantile,probs=.5)$y)
lines(x,locapply(x,y,quantile,probs=.9)$y)
lines(x,locapply(x,y,quantile,probs=.1)$y)
lines(x,locapply(x,y,quantile,probs=1)$y)
lines(x,locapply(x,y,quantile,probs=0)$y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.