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?
I'm using this variant for force print K decimal places:
# format numeric value to K decimal places formatDecimal <- function(x, k) format(round(x, k), trim=T, nsmall=k)