1 |
x |
|
y |
|
fr |
|
est |
|
nmin |
|
pts |
|
plotit |
|
xlab |
|
ylab |
|
... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, y, fr = 1, est = tmean, nmin = 10, pts = x, plotit = FALSE,
xlab = "X", ylab = "Y", ...)
{
temp <- cbind(x, y)
temp <- elimna(temp)
x <- temp[, 1]
y <- temp[, 2]
vals <- rep(NA, length(pts))
for (i in 1:length(pts)) {
flagl <- nearl(x, fr = fr, pts[i])
flagr <- nearr(x, fr = fr, pts[i])
flagr <- as.logical(flagr)
flagl <- as.logical(flagl)
if (sum(flagl) >= nmin && sum(flagr) >= nmin) {
yl <- est(y[flagl], ...)
yr <- est(y[flagr], ...)
xl <- est(x[flagl], ...)
xr <- est(x[flagr], ...)
vals[i] <- (yr - yl)/(xr - xl)
}
}
if (plotit) {
plot(c(x, x[1], x[2]), c(vals, -5, 5), xlab = xlab, ylab = ylab)
xord <- order(x)
lines(x[xord], vals[xord])
}
vals
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.