[R] unique and precision of long integers
Christophe Declercq
cdeclercq at nordnet.fr
Mon May 14 17:49:10 CEST 2001
Hi, Michael
> De : owner-r-help at stat.math.ethz.ch
> [mailto:owner-r-help at stat.math.ethz.ch]De la part de Michael Herron
> Envoyé : lundi 14 mai 2001 17:09
> À : r-help at stat.math.ethz.ch
> Objet : [R] unique and precision of long integers
>
>
>
> Hello.
>
> I have a dataset with about 500,000 observations, most of which are
> not unique. The first 10 observations look like
>
> 901000000000100000010100101011002
> 901101101110100000010100101011002
[...]
> I read in the data with scan(), and then use unique() to get the
> unique observations. But, when I print these elements to a file I
> lose precision.
If you have long strings of digits, you can 'scan' them as character
(actually, they are not exactly numbers) and manipulate them afterwards:
> x<-scan("foo.dat", what="")
> x
[1] "901000000000100000010100101011002"
"901101101110100000010100101011002"
[3] "901000000000100000010100000001002"
"901000000000100000010101001011002"
[5] "901000000000100000010101010011002"
"901000000000100000010100110101002"
[7] "901000000000100000010100101011002"
"900000000000100000010010101011002"
[9] "901000000000100000010100101101002"
"901000000000100000010100101011002"
> write(x,"",ncol=1)
901000000000100000010100101011002
901101101110100000010100101011002
901000000000100000010100000001002
901000000000100000010101001011002
901000000000100000010101010011002
901000000000100000010100110101002
901000000000100000010100101011002
900000000000100000010010101011002
901000000000100000010100101101002
901000000000100000010100101011002
I hope it helps.
Christophe
--
Christophe DECLERCQ, MD
Observatoire Régional de la Santé Nord-Pas-de-Calais
13, rue Faidherbe 59046 LILLE Cedex FRANCE
Phone +33 3 20 15 49 24
Fax +33 3 20 55 92 30
E-mail c.declercq at orsnpdc.org
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list