Skip to content

force fixed format

5 messages · Fredrik Lundgren, Göran Broström, John Fox +2 more

#
Hello,
A small problem I can't solve

 > p <- 0.0001
[1] 1e-04

How can I force the printout of p to 0.0001?
I have tried 'format', 'round', 'signif', 'print' in different combinations without success.
                      
Fredrik Lundgren
#
On Thu, Jan 01, 2004 at 09:04:41PM +0100, Fredrik Lundgren wrote:
You may check 'formatC':
[1] "0.0001"
#
At 09:04 PM 1/1/2004 +0100, Fredrik Lundgren wrote:
If the issue is general, try the scipen option:

 > options(scipen=10)
 > p <- 0.0001
 > p
[1] 0.0001

I hope that this helps,
  John
-----------------------------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario, Canada L8S 4M4
email: jfox at mcmaster.ca
phone: 905-525-9140x23604
web: www.socsci.mcmaster.ca/jfox
#
formatC(p,format="fg")
or
formatC(p,format="f",digits=#)

#-specify number of digits

should do the job.


 
Pravin
 
Pravin Jadhav

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Fredrik Lundgren
Sent: Thursday, January 01, 2004 3:05 PM
To: R-help
Subject: [R] force fixed format

Hello,
A small problem I can't solve

 > p <- 0.0001
[1] 1e-04

How can I force the printout of p to 0.0001?
I have tried 'format', 'round', 'signif', 'print' in different combinations
without success.
                      
Fredrik Lundgren

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
#
John Fox wrote:
To explain further: R normally prints in scientific notation if it requires
fewer characters than standard notation.  By setting options(scipen=10), you
are imposing an addition 10-character SCIentific notation PENalty whenever this
comparison is made.  Negative values would favor scientific notation.