1 |
x |
|
y |
|
z |
|
fr |
|
corflag |
|
corfun |
|
plotit |
|
rhat |
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 34 35 36 37 38 39 40 41 | ##---- 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, z, fr = 1, corflag = FALSE, corfun = pbcor, plotit = TRUE,
rhat = FALSE)
{
temp <- cbind(x, y, z)
temp <- elimna(temp)
x <- temp[, 1]
y <- temp[, 2]
z <- temp[, 3]
plotit <- as.logical(plotit)
rmd <- NA
if (!corflag) {
for (i in 1:length(x)) {
flag <- near(z, z[i], fr)
if (sum(flag) > 2)
rmd[i] <- corfun(x[flag], y[flag])$cor
}
}
if (corflag) {
for (i in 1:length(x)) {
flag <- near(z, z[i], fr)
if (sum(flag) > 2)
rmd[i] <- cor(x[flag], y[flag])
}
}
if (plotit) {
plot(c(max(z), min(z), z), c(1, -1, rmd), xlab = "Modifier",
ylab = "Correlation", type = "n")
sz <- sort(z)
zorder <- order(z)
sysm <- rmd[zorder]
lines(sz, sysm)
}
if (!rhat)
rmd <- "Done"
rmd
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.