Back
I would like to keep trailing zeros, for example, if I type:
round(5.2, 3)
I would like the output to be:
5.200
You can use the following functions to keep the trailing zeros while printing a number:
sprintf("%.3f", round(5.2,3))[1] "5.200"
sprintf("%.3f", round(5.2,3))
[1] "5.200"
formatC( round( 5.2, 3 ), format='f', digits=3 )[1] "5.200"
formatC( round( 5.2, 3 ), format='f', digits=3 )
If you want to learn more about R programming watch this tutorial on Introduction to Data Science with R
31k questions
32.8k answers
501 comments
693 users