Gents:

The "eval(parse(...))" construction should almost always be avoided: it is
basically a misuse of R. There are exceptions, I suppose, but this does not
appear to be one of them.

Note that the use of numeric indexing does appear to be slightly faster
than logical indexing here, although I would say not enough to make a
practical difference. In any case:

A <- mat1New ## saves me a bit of editing
>
  > system.time({
    +     j40<- n*seq_len(nrow(A)/n)
    +     vec1<- rep("j40",n)
    +     res<- eval(parse(text=
paste(paste0("A","[",paste0(vec1,"-",seq(n)-1),",]"),collapse="*")
                           +     ))
    + })
user  system elapsed
0.02    0.00    0.01

> system.time({
  +     j <- seq_len(nrow(A))%%n
  +     b <- A[j==0,]
  +     for(i in seq_len(n-1))b <- b*A[j==i,]
  + })
user  system elapsed
0.25    0.00    0.27


  > system.time({
    +     j <- n*seq_len(nrow(A)/n)
    +     b1 <- A[j,]
    +     for(i in seq_len(n-1))b1 <- b1*A[j-i,]
    + })
user  system elapsed
0.01    0.00    0.02

## One should not invest too much faith in such superficial timing tests,
however.

I will have no further comments.


Cheers,
Bert

	[[alternative HTML version deleted]]

