Re: [R] Integer vs numeric

2008-01-30 Thread Gabor Grothendieck
The : operator does give a numeric, non-integer result when integer would not be sufficient: 1.1:10.1 On Jan 30, 2008 9:28 AM, [EMAIL PROTECTED] wrote: Ok, I get your point. On the other hand, R is not only for high level programmer. On low level, the fact that : change the type is

Re: [R] Integer vs numeric

2008-01-30 Thread Henrik Bengtsson
On Jan 29, 2008 10:40 PM, Christophe Genolini [EMAIL PROTECTED] wrote: x[c(2,4)] work as well My point is that that at the native-code level subsetting/enumeration is done by integer indices and coercion from double to integer is always going to less efficient than working directly with

Re: [R] Integer vs numeric

2008-01-29 Thread cgenolin
Seems strange to me to define an operator relatively to a very special case. I have to admit that I do not use 1:1e7 every day :-) Wouldn't it be more appropriate to define a a:b operator numeric (that is preserving the initial class of a and b) and in specific case that need optimization,

Re: [R] Integer vs numeric

2008-01-29 Thread Henrik Bengtsson
x[1:n] /H On Jan 29, 2008 5:07 AM, [EMAIL PROTECTED] wrote: Seems strange to me to define an operator relatively to a very special case. I have to admit that I do not use 1:1e7 every day :-) Wouldn't it be more appropriate to define a a:b operator numeric (that is preserving the initial

Re: [R] Integer vs numeric

2008-01-29 Thread Christophe Genolini
x[c(2,4)] work as well Henrik Bengtsson a écrit : x[1:n] /H On Jan 29, 2008 5:07 AM, [EMAIL PROTECTED] wrote: Seems strange to me to define an operator relatively to a very special case. I have to admit that I do not use 1:1e7 every day :-) Wouldn't it be more appropriate to define

Re: [R] Integer vs numeric

2008-01-28 Thread Roland Rau
Christophe Genolini wrote: Hi the list. I do not understand the philosophy behind numeric and integer. - 1 is numeric (which I find surprising) - 2 is numeric. - 1:2 is integer. Why is that ? I hope I can answer your question at least partly: Numeric means double, i.e. internally

Re: [R] Integer vs numeric

2008-01-28 Thread Ted Harding
On 28-Jan-08 21:23:12, Roland Rau wrote: Christophe Genolini wrote: Hi the list. I do not understand the philosophy behind numeric and integer. - 1 is numeric (which I find surprising) - 2 is numeric. - 1:2 is integer. Why is that ? I hope I can answer your question at least partly:

Re: [R] Integer vs numeric

2008-01-28 Thread Ted Harding
On 28-Jan-08 22:40:02, Peter Dalgaard wrote: [...] AFAIR, space is/was more of an issue. If you do something like for i in 1:1e7 some.silly.simulation() then you have 40 MB sitting there doing nothing, and 80 MB if it had been floating point. Hmmm ... there's something to be said

Re: [R] Integer vs numeric

2008-01-28 Thread Peter Dalgaard
(Ted Harding) wrote: Further to the above: The help ?: says: Value: For numeric arguments [as opposed to factors], a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric'. By

Re: [R] Integer vs numeric

2008-01-28 Thread Christophe Genolini
Further to the above: The help ?: says: Value: For numeric arguments [as opposed to factors], a numeric vector. This will be of type 'integer' if 'from' and 'to' are both integers and representable in the integer type, otherwise of type 'numeric' ??? This is very