[R] dots expansion

Viet Nguyen vietnguyen at fastmail.fm
Wed Aug 4 05:08:41 CEST 2004


Thanks to all who helped.

I used your ideas and code samples to write the following (for the 
benefit of people who will search this list later):

rbind.case <- function(..., name="case", values) {
    dots <- list(...);
    if (missing(values)) values <- 1:length(dots);
    if (length(values)!=length(dots))
      stop("length(values)!=length(list(...))");

    eval(parse(text=
               paste("cbind(rbind(...), ",name,
                     "=rep(values, sapply(dots, nrow)))",sep="")));
}


The function is to be used with data frames. It's not as good as it can 
be but it works for my purpose.

Cheers
viet




More information about the R-help mailing list