On Sat, Mar 24, 2012 at 7:30 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > Do we have a format that always includes a decimal point and a given number > of significant digits, but otherwise drops unnecessary characters? For > example, if I wanted 5 digits, I'd want the following: > > Round to 5 digits: > 1.234567 -> "1.2346" > > Drop unnecessary zeros: > 1.23 -> "1.23" > > Force inclusion of a decimal point: > 1 -> "1." >
Duncan, Maybe sprintf() will work for you. As it's a wrapper for C sprintf, it should have its functionality. James ______________________________________________ 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.