Here is one way of getting the digits:

> x <- sprintf("%E", 0.000004)
> x
[1] "4.000000E-06"
> gsub("([[:digit:]]+$)", 
> substr("0000\\1",nchar("\\1")+1,nchar("\\1")+4<file://1%22)+1,nchar(%22//1%22)+4>),
x, perl=TRUE)
[1] "4.000000E-0006"
>


On Mon, Jun 9, 2008 at 12:56 PM, jim holtman <[EMAIL PROTECTED]> wrote:

> But be careful if your number does not contain only 0:
>
> > sprintf("%E00", pi*1000)
> [1] "3.141593E+0300"
> > sprintf("%E", pi*1000)
> [1] "3.141593E+03"
>
>
> On Mon, Jun 9, 2008 at 12:42 PM, Paulo Cardoso <[EMAIL PROTECTED]>
> wrote:
>
>> Yes works,
>>
>> Thank you Henrique.
>>
>> I'm so basic with R!
>>
>> Paulo
>>
>>
>>
>> From: Henrique Dallazuanna [mailto:[EMAIL PROTECTED]
>> Sent: segunda-feira, 9 de Junho de 2008 17:37
>> To: Paulo Cardoso
>> Cc: r-help@r-project.org
>> Subject: Re: [R] sprintf()
>>
>>
>>
>> Try:
>>
>> sprintf("%E00", pi)
>>
>> On Mon, Jun 9, 2008 at 1:28 PM, Paulo Cardoso <[EMAIL PROTECTED]>
>> wrote:
>>
>> Hi,
>>
>> I'm not being able to represent the result of sprintf("%E", pi)
>> [1] "3.141593E+00"
>>
>> Into this:
>> "3.141593E+0000"
>>
>> Thanks in advance
>>
>> Paulo
>>
>> ______________________________________________
>> R-help@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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>>
>> --
>> Henrique Dallazuanna
>> Curitiba-Paraná-Brasil
>> 25° 25' 40" S 49° 16' 22" O
>>
>> No virus found in this incoming message.
>> Checked by AVG.
>>
>> 11:17
>>
>>
>>        [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help@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<http://www.r-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem you are trying to solve?




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to