Pietrzykowski, Matthew (GE, Research)
2007-May-03 16:14 UTC
[R] Truncating trailing digits
Hello, I am relatively new to R and have a rudimentary question, I think. How does one truncate the number of digits displayed after the decimal when viewing the results of analyses? My apologies if this question has been answered previously, I was not able to find references very easily. Thank you in advance, Matt [[alternative HTML version deleted]]
On Thu, 2007-05-03 at 12:14 -0400, Pietrzykowski, Matthew (GE, Research) wrote:> Hello, > > I am relatively new to R and have a rudimentary question, I think. How > does one > truncate the number of digits displayed after the decimal when viewing > the results > of analyses? > > My apologies if this question has been answered previously, I was not > able to find > references very easily. > > Thank you in advance, > > MattThe answer is "it depends". There are user configurable options in R that determine how default output is displayed, relative to the number of significant digits and the use of scientific notation. See ?options for more information, specifically 'digits' and 'scipen'. These don't necessarily guarantee a fixed number of digits after the decimal however. If you are creating your own output functions and want greater control over the formatting (ie. column alignment, etc.), including specifically the number of digits after the decimal, then see ?formatC and ?sprintf which allow for this. Also see ?cat which is how much of standard R console output is generated. HTH, Marc Schwartz
Perhaps format is what you are looking for: ?format Charles Annis, P.E. Charles.Annis at StatisticalEngineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Pietrzykowski, Matthew (GE, Research) Sent: Thursday, May 03, 2007 12:14 PM To: r-help at stat.math.ethz.ch Subject: [R] Truncating trailing digits Hello, I am relatively new to R and have a rudimentary question, I think. How does one truncate the number of digits displayed after the decimal when viewing the results of analyses? My apologies if this question has been answered previously, I was not able to find references very easily. Thank you in advance, Matt [[alternative HTML version deleted]] ______________________________________________ R-help at 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 and provide commented, minimal, self-contained, reproducible code.