[EMAIL PROTECTED] writes: > Thanks for the reply Peter, though I'm not quite convinced. > > > > #dubious.records = integer(0) > > > identical(dubious.records, -dubious.records) > > [1] TRUE > > > how can peoples.heights[-dubious.records,] be different from > > peoples.heights[dubious.records,]? > > Tell me if I'm being willfully ignorant here, but I'm sure they should be > different. In the first case, the minus sign represents subtraction, so > it is correct that dubious.records and -dubious.records are identical. > > However, in the second case, inside the square brackets, the minus sign > represents set complement, not subtraction, so dubious.records and - > dubious.records are not the same.
Nono, that is the point: Minus is minus, no matter where it occurs. Changing what it means depending on context leads to inconsistent behaviour. E.g., you shouldn't get different behaviour from assigning an index expression to an intermediate variable, as in peoples.heights[-dubious.records,] keep <- -dubious.records peoples.heights[keep,] However, that would happen if the minus was interpreted differently within []: There is no way for R to realize that the sign change in the assignment has anything to do with indexing (OK, there is, but then the value of "keep" later on would depend on what it had been used for! Things quickly get really nasty). -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [email protected] 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.
