[R] Problem with long number (from character to numeric class)

jim holtman jholtman at gmail.com
Wed Feb 9 15:15:11 CET 2011


FAQ 7.31

For 'numerics' there is a limit of about 15 digits of accuracy in the number.

On Wed, Feb 9, 2011 at 7:15 AM, PtitBleu <ptit_bleu at yahoo.fr> wrote:
>
> Hello,
>
> I have a text file with one column containing long number but stored as
> string.
> I download the file with read.table (and colClass) and the first row of this
> column is :
>
> "095842087016731010"
>
> As I need to make some calculations with these numbers, I tried to convert
> them using as.numeric.
> But then I get
> as.numeric("095842087016731010")
> 95842087016731008
>
> I understand the disappearing of the first 0 but I don't understand the
> substitution of the last 0 by 8.
>
> Is there a way to avoid that ?
> Thanks in advance,
> Ptit Bleu.
> --
> View this message in context: http://r.789695.n4.nabble.com/Problem-with-long-number-from-character-to-numeric-class-tp3297121p3297121.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list