I have a number, for example 1.128347132904321674821 that I would like to show as only two decimal places when output to screen (or written to a file). How does one do that?
If you prefer significant digits to fixed digits then, the signif command might be useful:
> signif(1.12345, digits = 3) [1] 1.12 > signif(12.12345, digits = 3) [1] 12.1 > signif(12345.12345, digits = 3) [1] 12300