Skip to content

how does R represent numbers?

2 messages · Bill Simpson, Brian Ripley

#
I just found out that R assumes that vectors created with the : operator
are integer:
[1] TRUE

Vectors created with seq() can be integer
[1] TRUE

or double
[1] FALSE

The vector is double if I do it like this:
[1] FALSE

rep() seems to make doubles:
[1] FALSE

A single number with no decimal place is double:
[1] FALSE
This is the reason I previously thought all numbers were double in R.


Maybe there's a good reason for this situation, but it seems strange and
inconsistent to me.

This might be a silly suggestion, but how about:
* all numbers assumed to be double unless explicitly set as integer *
* using integer() or changed to integer using as.integer()          *


Bill

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Thu, 13 Sep 2001, Bill Simpson wrote:

            
All as documented in ?seq.
There are good reasons for this, the main one being that systems
should work as advertised.

There are other sorts of numbers in R too, BTW.  (Hint: what are the five
atomic vector types?)