1 |
x |
|
outfun |
|
xlab |
|
ylab |
|
zlab |
|
reg.plane |
|
regfun |
|
COLOR |
|
tick.marks |
|
... |
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, outfun = outpro, xlab = "Var 1", ylab = "Var 2",
zlab = "Var 3", reg.plane = FALSE, regfun = tsreg, COLOR = FALSE,
tick.marks = TRUE, ...)
{
if (!is.matrix(x) && !is.data.frame(x))
stop("Data must be stored in a matrix\nor data frame with 3 columns.")
if (ncol(x) != 3)
stop("Data must be stored in a matrix with 3 columns.")
x = as.matrix(x)
x <- elimna(x)
library(scatterplot3d)
temp <- scatterplot3d(x, xlab = xlab, ylab = ylab, zlab = zlab,
tick.marks = tick.marks)
outid <- outfun(x)$out.id
if (!is.na(outid[1])) {
if (COLOR) {
if (length(outid) == 1)
temp$points(t(as.matrix(x[outid, ])), col = "red")
if (length(outid) > 1)
temp$points(x[outid, ], col = "red")
}
if (!COLOR) {
if (length(outid) == 1)
temp$points(t(as.matrix(x[outid, ])), pch = "*")
if (length(outid) > 1)
temp$points(x[outid, ], pch = "*")
}
}
if (reg.plane) {
vals <- regfun(x[, 1:2], x[, 3], ...)$coef
if (COLOR)
temp$plane(vals, col = "blue")
if (!COLOR)
temp$plane(vals)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.