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
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
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
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]
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 ...
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
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
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]
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