View source: R/fillUpDecimals.R
fillUpDecimals | R Documentation |
The function adds zeros after the decimal point of each element of a numeric vector so that all elements have the same number of digits after the decimal point.
fillUpDecimals(numVec, howManyToFill, fill)
numVec |
A vector of numbers in a numeric or character format. |
howManyToFill |
The target number of digits after the decimal point. If |
fill |
What character to insert as a filler to reach the target number of digits (characters) after the decimal point. The default is |
The function adds zeros (or other characters) after the decimal point of each element of numVec
so that all elements have the same number of decimal places after the decimal point. Lower and upper case letters are treated as digits (see the examples). NA
values are returned unchanged. It is not recommended to include elements with characters other than digits and letters into numVec
because the function will not work as described for these elements.
A character string with equal number of decimal places after the decimal point.
Svetlana K Eden, svetlanaeden@gmail.com
fillUpDecimals(c("2", "3.4", "A", NA)) fillUpDecimals(c("2", "3.4", "A.5", NA), howManyToFill = 3) fillUpDecimals(c("2", "3.4", "A", NA), fill = "X") fillUpDecimals(c("2", "3.4", "A", NA), howManyToFill = -3) fillUpDecimals(c("2", "3.4", "A.zx", NA), fill = "?") ### It is not recommended to include elements ### with characters other than digits and letters ### because the function will not work as described ### for these elements fillUpDecimals(c("2", "3.4", "A.zx", NA, "#", "#a"), fill = "?")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.