[R] numerical accuracy, dumb question
Marc Schwartz
MSchwartz at MedAnalytics.com
Sat Aug 14 04:41:53 CEST 2004
Part of that decision may depend upon how big the dataset is and what is
intended to be done with the ID's:
> object.size(1011001001001)
[1] 36
> object.size("1011001001001")
[1] 52
> object.size(factor("1011001001001"))
[1] 244
They will by default, as Andy indicates, be read and stored as doubles.
They are too large for integers, at least on my system:
> .Machine$integer.max
[1] 2147483647
Converting to a character might make sense, with only a minimal memory
penalty. However, using a factor results in a notable memory penalty, if
the attributes of a factor are not needed.
If any mathematical operations are to be performed with the ID's then
leaving them as doubles makes most sense.
Dan, more information on the numerical characteristics of your system
can be found by using:
.Machine
See ?.Machine and ?object.size for more information.
HTH,
Marc Schwartz
On Fri, 2004-08-13 at 21:02, Liaw, Andy wrote:
> If I'm not mistaken, numerics are read in as doubles, so that shouldn't be a
> problem. However, I'd try using factor or character.
>
> Andy
>
> > From: Dan Bolser
> >
> > I store an id as a big number, could this be a problem?
> >
> > Should I convert to at string when I use read.table(...
> >
> > example id's
> >
> > 1001001001001
> > 1001001001002
> > ...
> > 1002001002005
> >
> >
> > Bigest is probably
> >
> > 1011001001001
> >
> > Ta,
> > Dan.
> >
More information about the R-help
mailing list