1 | selbybbw(m, grpc, coln, pr = T)
|
m |
|
grpc |
|
coln |
|
pr |
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 42 43 44 45 46 47 | ##---- 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 (m, grpc, coln, pr = T)
{
if (is.na(grpc[1]))
stop("The argument grpc is not specified")
if (is.na(coln[1]))
stop("The argument coln is not specified")
if (length(grpc) != 2)
stop("The argument grpc must have length 2")
mm = m
m <- as.data.frame(elimna(mm))
x <- list()
grp1 <- sort(unique(m[, grpc[1]]))
grp2 <- sort(unique(m[, grpc[2]]))
if (pr) {
print("Levels for first factor:")
print(grp1)
print("Levels for second factor:")
print(grp2)
}
J <- length(grp1)
K <- length(grp2)
L <- length(coln)
JKL <- J * K * L
itt <- 0
it = 0
mm = as.matrix(m[, coln])
gmat = matrix(NA, ncol = 2, nrow = J * K)
for (ig1 in 1:length(grp1)) {
for (ig2 in 1:length(grp2)) {
itt = itt + 1
gmat[itt, ] = c(grp1[ig1], grp2[ig2])
for (ic in 1:length(coln)) {
it <- it + 1
flag <- (m[, grpc[1]] == grp1[ig1]) * (m[, grpc[2]] ==
grp2[ig2])
flag = as.logical(flag)
x[[it]] <- as.numeric(mm[flag, ic])
}
}
}
x
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.