If this is for printing purposes, sprintf
is what you are after:
> sprintf("%.3f", round(5.2,3))
[1] "5.200"
See ?sprintf
for formatting details.
More Related Contents:
- Formatting Decimal places in R
- Round up from .5
- Check if the number is integer
- How to round up to the nearest 10 (or 100 or X)?
- R round to nearest .5 or .1
- Angle between two vectors in R
- Position of the sun given time of day, latitude and longitude
- Solving non-square linear system with R
- Extreme numerical values in floating-point precision in R
- Rounding numbers in R to specified number of digits
- Why does NaN^0 == 1
- R issue with rounding milliseconds
- how to plot ellipse given a general equation in R?
- Round a POSIX date (POSIXct) with base R functionality
- How to resolve a Java Rounding Double issue [duplicate]
- Filter rows which contain a certain string
- Apply function conditionally
- Select every other element from a vector
- R dplyr rolling sum
- Using multiple criteria in subset function and logical operators
- Can’t download data from Yahoo Finance using Quantmod in R
- Creating regular 15-minute time-series from irregular time-series
- Unlist a data frame by rows, not columns
- How do you delete a column by name in data.table?
- Applying a function to two lists?
- Merging two sets of data by data.table roll=’nearest’ function
- Drawing a barchart to compare two sets of data using ggplot2 package?
- Applying a function to each row of a data.table
- R: Calculate cosine distance from a term-document matrix with tm and proxy
- Programming-safe version of subset – to evaluate its condition while called from another function