> >  dat[- integer(0), ]
> > .... unexpectedly omits ALL rows
> >
> > It would be less surprising if there were no rows omitted in the (B) case.

I tried this on two experienced R users here and their first thought* was, 
interestingly, as Jack indicated; that -integer(0) should drop nothing.

But Gerrit is correct; -integer(0) still evaluates to a zero length vector, not 
a negative, and asking for a zero-length set of rows is equivalent to asking 
for no rows.

Steve E

*Second thought, actually; their first thought was 'why would you do that?'. 
To be fair we did note that dropping according to an empty 'which' criterion or 
an unmatched grep() would do this. The 'obvious' fix would presumably be not to 
wrap the selection in which() at all (eg use 1:5 == 6 directly and not 
which(1:5 == 6) ), to use regexpr(...)>0 instead of grep etc. 




*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to