[R] 1 not equal to 1, and rep command
djnordlund at frontier.com
Mon Sep 12 19:01:57 CEST 2011
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of Benjamin Høyer
> Sent: Monday, September 12, 2011 6:19 AM
> To: r-help at r-project.org
> Cc: tapo at novozymes.com
> Subject: [R] 1 not equal to 1, and rep command
> I need to use rep() to get a vector out, but I have spotted something very
> strange. See the reproducible example below.
> N <- 79
> seg <- 5
> segN <- N / seg # = 15.8
> d1 <- seg - ( segN - floor(segN) ) * seg
> d1 # = 1
Not on my machine.
See FAQ 7.31
> rep(2, d1) # = numeric(0), strange - why doesn't it print one
> Seems like there's some binary maths errors here somewhere. Very strange
> me. Anyway, I need to be able to use the result d1 in a rep() command.
> way to force rep not to be *too* specific in how it reads its "times"
Maybe round() will work for you, since you seem to be expecting a whole number.
Hope this is helpful.
Bothell, WA USA
More information about the R-help