Hello, A small problem I can't solve > p <- 0.0001> p[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:> Hello, > A small problem I can't solve > > > p <- 0.0001 > > p > [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.You may check 'formatC':> formatC(p)[1] "0.0001" -- G?ran Brostr?m tel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Ume? University http://www.stat.umu.se/egna/gb/ SE-90187 Ume?, Sweden e-mail: gb at stat.umu.se
At 09:04 PM 1/1/2004 +0100, Fredrik Lundgren wrote:>Hello, >A small problem I can't solve > > > p <- 0.0001 > > p >[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. >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> p[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:> If the issue [of suppressing scientific notation] is general, try the scipen > option: > > options(scipen=10) > > p <- 0.0001 > > p > [1] 0.0001To 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. -- -- David Brahm (brahm at alum.mit.edu)