Re: [R] Integer vs numeric

From: Roland Rau <roland.rproject_at_gmail.com>
Date: Mon, 28 Jan 2008 16:23:12 -0500

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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 28 Jan 2008 - 21:28:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Jan 2008 - 23:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive