[Rd] number formsat

Simon Urbanek simon.urbanek at r-project.org
Thu Feb 14 23:59:53 CET 2008


Hill0093,

On Feb 14, 2008, at 5:43 PM, hill0093 wrote:

> PROBLEM ONE
> In my way of using R in print and plots,
> R severely ignores formatting requests for numbers.
> E.g.,
>> n1=2008021323595999
>> n1
> [1] 2.008021e+15
>> print(n1,digits=16)
> [1] 2008021323595999
>> print(n1,digits=18)
> [1] 2008021323595999
>> print(n1,digits=15)
> [1] 2008021323595999

You are not requesting specific formatting, you are requesting  
*significant digits* hence the above is as expected. For output  
formatting, see ?sprintf and ?formatC.


> The e+15 form for similar numbers also  appears in the tic mark  
> labels in plots,  but with yet other counts of significant digits.
> PROBLEM TWO
> I need to use a function that I could write, since I have done it in  
> several other languages, to convert my calendar times of various   
> lengths into linear time as I read the data. Then I need to use an  
> inverse function to  convert the linear time for the tic mark labels  
> of plots of the data, and for printouts.
> Where do I look to learn how to do this in R?
>

Time types in R are linear, try using them (see ?DateTimeClasses and ? 
as.POSIXct).

Please post help requests to R-help in the future.

Thanks,
Simon



More information about the R-devel mailing list