How can I cut the decimals of a quotient in R? I'm computing millions of values and write them in a file on the fly. To save some space I don't want more than five decimals and also omit trailing zeros.
format(x, nsmall = 5)
How about with just
round(x,5) x=1.23456777 round(x,5) # 1.23457 x=1.230000 #round(x,5)  1.23
If you don't want rounding try this:
as.integer(x*10^5)/10^5 x=1.234567777 as.integer(x*10^5)/10^5 # 1.23456 x=1.230000 as.integer(x*10^5)/10^5 # 1.23