Rép : [R] 2 small problems: integer division and the nature of NA

2005-02-05 Thread Denis Chabot
), levels.mean=T) k5 - as.numeric(levels(k7))[k7] I could round to 1 decimal to be even more exact but this is good enough. If it can be more elegant, please let me know! Denis Subject: [R] 2 small problems: integer division and the nature of NA Hi, I'm wondering why 48 %/% 2 gives 24 but 4.8

[R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Denis Chabot
Hi, I'm wondering why 48 %/% 2 gives 24 but 4.8 %/% 0.2 gives 23... I'm not trying to round up here, but to find out how many times something fits into something else, and the answer should have been the same for both examples, no? On a different topic, I like the behavior of NAs better in R

Re: [R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Uwe Ligges
Denis Chabot wrote: Hi, I'm wondering why 48 %/% 2 gives 24 but 4.8 %/% 0.2 gives 23... I'm not trying to round up here, but to find out how many times something fits into something else, and the answer should have been the same for both examples, no? No. Not from the perspective of a digital

Re: [R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Spencer Graves
It's the difference between integers and reals: 48 and 24 are integers; 4.8 and 0.2 are floating point numbers. Consider: (4.8+.Machine$double.eps) %/% (0.2-.Machine$double.eps) [1] 24 (4.8-.Machine$double.eps) %/% (0.2+.Machine$double.eps) [1] 23 Does this help? spencer graves

Re: [R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Peter Dalgaard
Denis Chabot [EMAIL PROTECTED] writes: Hi, I'm wondering why 48 %/% 2 gives 24 but 4.8 %/% 0.2 gives 23... I'm not trying to round up here, but to find out how many times something fits into something else, and the answer should have been the same for both examples, no? Well, you

RE: [R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Huntsinger, Reid
@stat.math.ethz.ch Subject: [R] 2 small problems: integer division and the nature of NA Hi, I'm wondering why 48 %/% 2 gives 24 but 4.8 %/% 0.2 gives 23... I'm not trying to round up here, but to find out how many times something fits into something else, and the answer should have been the same for both

Re: [R] 2 small problems: integer division and the nature of NA

2005-02-04 Thread Gabor Grothendieck
Denis Chabot chabotd at globetrotter.net writes: : The sum of a vector having at least one NA but also valid data gives NA : if we do not specify na.rm=T. But with na.rm=T, we are telling sum to : give the sum of valid data, ignoring NAs that do not tell us anything : about the value of a