1 |
data |
|
ndirect |
|
seed |
|
all |
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 | ##---- 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 (data, ndirect, seed = 0, all = T)
{
n <- nrow(data)
p <- ncol(data)
B2 <- matrix(data = 0, nrow = ndirect, ncol = p)
rowindex <- 1
i <- 1
if (all == T) {
while ((i < n) & (rowindex <= ndirect)) {
j <- i + 1
while ((j <= n) & (rowindex <= ndirect)) {
B2[rowindex, ] <- data[i, ] - data[j, ]
j <- j + 1
rowindex <- rowindex + 1
}
i <- i + 1
}
}
else {
while (rowindex <= ndirect) {
sseed <- randomset(n, 2, seed)
seed <- sseed$seed
B2[rowindex, ] <- data[sseed$ranset[1], ] - data[sseed$ranset[2],
]
rowindex <- rowindex + 1
}
}
return(B2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.