Re: [R] engineering notation format

From: Walker, Sam <s-walker_at_ti.com>
Date: Sat 08 Jul 2006 - 00:17:00 EST


Clever...

Good observation on the last example, mistake on my part.

Thanks for all the suggestions.

Sam

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Hans-Joerg Bibiko Sent: Friday, July 07, 2006 4:27 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] engineering notation format

Hi,

try this:

formatEng <- function(x) {

   s<-as.numeric(strsplit(format(x, scientific=T),"e")[[1]])    return(paste(s[1]*10^(s[2]%%3),as.integer(s[2]-(s[2]%%3)),sep="e")) }

>>
>> Some examples:
>>
>> 1635 000 000 => 1.635E9
>> 163 500 000 => 163.5E6
>> 0.000 000 000 135 != 135E-9
>> 0.000 000 000 135 => 125E-12 ?

Hans



Hans-Joerg Bibiko
Max Planck Institute for Evolutionary Anthropology Department of Linguistics
Deutscher Platz 6     phone:   +49 (0) 341 3550 341
D-04103 Leipzig       fax:     +49 (0) 341 3550 333
Germany               e-mail:  bibiko@eva.mpg.de

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 08 00:30:05 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 08 Jul 2006 - 02:15:45 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.