[R] integer and character conversion

Benilton Carvalho bcarvalh at jhsph.edu
Sun Aug 23 07:13:07 CEST 2009


it's 'scipen' you want to look at.. b
On Aug 22, 2009, at 11:16 PM, David Winsemius wrote:

>
> On Aug 22, 2009, at 6:13 PM, Dajiang J. Liu wrote:
>
>> Dear all,I want to convert a long integer to a string, and for
>> example,
>> 100000000
>> I used as.character(1000000000) e.g, and it gives me back 1e+???.
>> What I
>> want is a exact form, not exponential form. Any ideas how to do it?
>> Thank
>
> The numeric ("double") type is not "exact" in R. (Read the FAQ) You
> can specify an integer by appending an "L" but that will limit the
> magnitude.
>
>> 1000000000L
> [1] 1000000000
>
>> 10000000000L
> [1] 1e+10
> Warning message:
> non-integer value 10000000000 qualified with L; using numeric value
>
> You are supposed to have control of the length of displayed decimal
> numbers with the option for "digits" but it doesn't work for me:
>
>> options("digits" = 12)
>> print(1000000000)
> [1] 1e+09
>> 1000000000
> [1] 1e+09
>
> --
> David Winsemius
>
> ______________________________________________
> 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.




More information about the R-help mailing list