[Rd] combn implementation
Giampiero Salvi
giampi at kth.se
Fri Jan 19 14:21:24 CET 2007
Hi,
I was checking the source code to the function combn that "generates
all combinations of the elements of 'x' taken 'm' at a time.",
because I wished to modify it. I have a doubt about a statement.
This is the main loop.
._1 <- 1:1
nmmp1 <- n - m + ._1
while (a[1] != nmmp1) {
if (e < n - h) {
h <- ._1
e <- a[m]
j <- ._1
}
else {
e <- a[m - h]
h <- h + ._1
j <- 1:h
}
a[m - h + j] <- e + j
r <- if (nofun)
x[a]
else FUN(x[a], ...)
if (simplify)
out[, i] <- r
else out[[i]] <- r
i <- i + 1
}
I wonder what is the meaning of the statement "._1 <- 1:1".
First question: what is the difference with "._1 <- 1"?
Second question (perhaps answerd by the answer to the first): why not
using "1" directly? E.g.:
[...]
h <- 1
e <- a[m]
e <- 1
[...]
Sorry if this is covered by the manuals, but it's not easy to search
for the string "._1" with the usual search engines.
Thank you!
Giampiero
More information about the R-devel
mailing list