[R] R internal data types
Martin Maechler
maechler at stat.math.ethz.ch
Thu Jan 15 09:36:18 CET 2004
>>>>> "Benjamin" == Benjamin STABLER <Benjamin.STABLER at odot.state.or.us>
>>>>> on Wed, 14 Jan 2004 15:52:46 -0800 writes:
<........>
Benjamin> So it looks like R stores numbers as doubles
Benjamin> unless the are converted to integers (long) with
Benjamin> the as.integer() function or they are created with
Benjamin> the : operator.
+/- yes;
In most cases, this should not matter though.
There are a few other functions that return integer ``by
definition'', e.g.,
length(), dim(), nrow(), ncol() {the latter 3 return 'NULL' or an integer}.
Benjamin> If any of the numbers to a function are not type
Benjamin> integer than the function returns type double. Is
Benjamin> this the case?
Most functions will return double even when all numeric arguments are
integer. Also, e.g. length() will return integer() in any case.
Only for some "arithmetic" functions
(+, -, *, %%, %/%, also min(), max(), sum())
your statement is true.
But really, in most cases, code shouldn't rely on this.
Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27
ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND
phone: x-41-1-632-3408 fax: ...-1228 <><
More information about the R-help
mailing list