[R] Integer vs numeric

Roland Rau roland.rproject at gmail.com
Mon Jan 28 22:23:12 CET 2008


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 stored as a double precision 
floating point number. As far as I know this is the default.
You can, however, force an object to be, e.g. an integer, a single 
prevision float or a double precision float.
as.integer(12)
as.single(12)
as.double(12)

So far I only needed this if I wanted to call some C or Fortran code.
Maybe there are other applications when you need to force the type?

I hope this helps at least a bit further?

Roland



More information about the R-help mailing list