On Mon, 17 Jan 2005 16:49:35 +0100 (MET) Christian Hennig wrote: > Hi, > > I would like to use the format function to get numbers all with three > digits to the right of the decimal point, even in cases where there is > no significant digit left. For example, I would like to get > c(0.3456789,0.0000053) as "0.346" "0.000". > It seems that it is not possible to force format to print a "0.000", > i.e. without any significant decimal places. > Is it possible to do this somehow in R?
You can round() before: R> x <- c(0.3456789,0.0000053) R> round(x, digits = 3) [1] 0.346 0.000 R> format(round(x, digits = 3)) [1] "0.346" "0.000" hth, Z > Thanks, > Christian > > > ********************************************************************* > ** Christian Hennig > Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg > [EMAIL PROTECTED], > http://www.math.uni-hamburg.de/home/hennig/ > ##################################################################### > ### > ich empfehle www.boag-online.de > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
