Re: [R] The "less than" (<) operator doesnt seem to perform as expected

2012-02-02 Thread Petr Savicky
On Thu, Feb 02, 2012 at 10:00:58AM +, Jonas Hal wrote: > The example here puzzles me. It seems like the < operator doesn't work as > expected. > > > l <- 0.6 > > u <- seq(0.4, 0.7, 0.1) > > u > [1] 0.4 0.5 0.6 0.7 > > mygrid <- expand.grid("l" = l, "u" = u) > > mygrid > l u > 1 0.6 0.4

Re: [R] The "less than" (<) operator doesnt seem to perform as expected

2012-02-02 Thread R. Michael Weylandt
It's likely an infelicity of floating point representations (R FAQ 7.31) but admittedly, not a case I would have expected to present itself. If you want it to work out as expected, try this: l <- 0.6 u <- seq(0.4, 0.7, 0.1) l.int <- (6L) / 10 u.int <- seq(4, 7) / 10 l < u l.int < u.int Michael

Re: [R] The "less than" (<) operator doesnt seem to perform as expected

2012-02-02 Thread Sarah Goslee
This is R FAQ 7.31, about machine representation of floating point numbers. > mygrid$u[3] - mygrid$l[3] [1] 1.110223e-16 So mygrid$l[3] < mygrid$u[3] is true, though the difference is very, very small and due solely to the limitations of computers. Sarah On Thu, Feb 2, 2012 at 5:00 AM, Jonas Ha

Re: [R] The "less than" (<) operator doesnt seem to perform as expected

2012-02-02 Thread William Dunlap
.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Jonas Hal > Sent: Thursday, February 02, 2012 2:01 AM > To: r-help@r-project.org > Subject: [R] The "less than" (<) operator doesnt seem to perform as expected > > The example here puzzles me. It seems like the &

[R] The "less than" (<) operator doesnt seem to perform as expected

2012-02-02 Thread Jonas Hal
The example here puzzles me. It seems like the < operator doesn't work as expected. > l <- 0.6 > u <- seq(0.4, 0.7, 0.1) > u [1] 0.4 0.5 0.6 0.7 > mygrid <- expand.grid("l" = l, "u" = u) > mygrid l u 1 0.6 0.4 2 0.6 0.5 3 0.6 0.6 4 0.6 0.7 > mygridcollapsed <- mygrid[mygrid$l < mygrid$u, ]