Skip to content
Prev 22456 / 398502 Next

[ and setMethod conflict?

Definitely something funny going on, but perhaps a little less sweeping
than your comments suggest.

No explanation at the moment, but a couple of clues.

1.  The problem doesn't seem to arise unless the data frame is large
enough.  I parametrized the 5000 rows in your example and couldn't get
the bizarre behavior until the number of rows was larger than 1000.

2.  There is some reason to think that nested "[" expressions are
related.  After rewriting your testFunc as follows, the random errors
seemed to go away.

testFunc <- function(cur) {
    ii <- order(cur[,1])
  sorted <- cur[ii,]
    ll <- !is.na(sorted[,1])
   sorted[ll,]
 }
(the change is just to pull out the subset expressions that were
arguments to other "[" expressions.)

I'm not an expert on R internals, but the combination of these might
suggest garbage collection taking place in nested calls to the dispatch
code for "[".

John Chambers

PS:  this thread might be more suited to r-devel than r-help.
"Bartz, Kevin" wrote: