1 |
x |
|
fun |
|
regfun |
|
type |
|
legend |
|
trace.label |
|
fixed |
|
xlab |
|
ylab |
|
xtick |
|
xaxt |
|
axes |
|
fit.lin |
|
... |
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 | ##---- 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, fun = mean, regfun = tsreg, type = c("l", "p", "b",
"o", "c"), legend = FALSE, trace.label = deparse(substitute(trace.factor)),
fixed = FALSE, xlab = "Time", ylab = "", xtick = FALSE, xaxt = par("xaxt"),
axes = TRUE, fit.lin = FALSE, ...)
{
x = as.matrix(x)
n = nrow(x)
p = ncol(x)
np = n * p
m = matrix(NA, nrow = np, 3)
pvec = c(1:p)
ic = 1 - p
iu = 0
for (i in 1:n) {
ic = ic + p
iu = iu + p
m[ic:iu, 1] = i
m[ic:iu, 2] = pvec
m[ic:iu, 3] = x[i, ]
}
if (!fit.lin)
interaction.plot(m[, 2], m[, 1], m[, 3], xlab = xlab,
ylab = ylab, legend = legend, xtick = xtick, xaxt = xaxt,
axes = axes)
if (fit.lin) {
fit = by(m[, 2:3], m[, 1], regYval, regfun = regfun)
fit1 <- unlist(fit)
names(fit1) <- NULL
interaction.plot(m[, 2], m[, 1], fit1, xlab = xlab, ylab = ylab,
legend = legend)
}
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.