I think your rewrite is overdue, because returning the array from the which function seems counterintuitive. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity.
Rumen Kostadinov <rkost...@gmail.com> wrote: Dear all, I found a bug in the which() function. When trying to remove elements with the which function, if the criteria is not matched, numeric(0) is returned instead of the array itself. This is very weird. > a = c(1,2,3,4,5) > a[!a==6] [1] 1 2 3 4 5 > a[-which(a==6)] numeric(0) > a[-which(a==5)] [1] 1 2 3 4 > a[!a==5] [1] 1 2 3 4 Is this correct? I believe this is a bug. I have to rewrite a lot of my R code to use a = a[!criteria] and not a = a[-which(criteria)] R._____________________________________________ 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. [[alternative HTML version deleted]] ______________________________________________ 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.