[Rd] combn implementation

From: Giampiero Salvi <giampi_at_kth.se>
Date: Fri 19 Jan 2007 - 13:21:24 GMT


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



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Jan 20 00:29:28 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 19 Jan 2007 - 14:31:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.