[R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Thomas Bock
Dear list, I can not understand why the expression in the subject does not work correct: dcrn[which(fn == inve[2])] numeric(0) inve[2] [1] 406.7 dcrn[which(fn == 406.7)] [1] 1.3994e-07 1.3988e-07 1.3953e-07 1.3966e-07 1.3953e-07 1.3968e-07 Is this a kick self problem or an bug? Thaks very

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Achim Zeileis
On Wednesday 08 October 2003 11:27, Thomas Bock wrote: Dear list, I can not understand why the expression in the subject does not work correct: dcrn[which(fn == inve[2])] numeric(0) inve[2] [1] 406.7 dcrn[which(fn == 406.7)] [1] 1.3994e-07 1.3988e-07 1.3953e-07 1.3966e-07

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Peter Dalgaard BSA
Thomas Bock [EMAIL PROTECTED] writes: Dear list, I can not understand why the expression in the subject does not work correct: dcrn[which(fn == inve[2])] numeric(0) inve[2] [1] 406.7 dcrn[which(fn == 406.7)] [1] 1.3994e-07 1.3988e-07 1.3953e-07 1.3966e-07 1.3953e-07 1.3968e-07

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Martin Maechler
Your question has been answered by Achim and Peter Dalgaard (at least). Just a note: Using a[which(logic)] looks like a clumsy and inefficient way of writing a[ logic ] and I think you shouldn't propagate its use ... Martin Maechler [EMAIL PROTECTED]

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Tony Plate
At Wednesday 03:06 PM 10/8/2003 +0200, Martin Maechler wrote: Your question has been answered by Achim and Peter Dalgaard (at least). Just a note: Using a[which(logic)] looks like a clumsy and inefficient way of writing a[ logic ] and I think you shouldn't propagate its use ...

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Gabor Grothendieck
Here are some different ways of doing this. Don't know whether any could be considered superior to the others. # y[x==5] regarding NAs in x as not matching x - c(5, NA, 7, 5, NA, 3) y - c(1, 2, 3, 4, 5, 6) subset(y,x==5) y[x %in% 5] y[x %in% c(5)] y[which(x==5)] --- Date: Wed, 08 Oct 2003

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Jason Turner
Achim Zeileis wrote: On Wednesday 08 October 2003 11:27, Thomas Bock wrote: ... I can not understand why the expression in the subject does not work correct: dcrn[which(fn == inve[2])] numeric(0) inve[2] [1] 406.7 ... 1.) `==' comparisons have a certain tolerance 2.) the print output is

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Jason Turner
Whoops. Hit send too quickly. Jason Turner wrote: tol - sqrt(.Machine$double.eps) dcrn[(fn - inve[2]) tol] that should be dcrn[abs(fn - inve[2]) tol] -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 [EMAIL PROTECTED]

Re: [R] Why does a[which(b == c[d])] not work?

2003-10-08 Thread Richard A. O'Keefe
Achim Zeileis [EMAIL PROTECTED] wrote: R x - 406.7 + 1e-20 R x [1] 406.7 R x == 406.7 [1] TRUE that is 1.) `==' comparisons have a certain tolerance No, all.equal() supports tolerance, == does not. Consider