numdec {admisc} | R Documentation |
Count number of decimals
Description
Calculates the (maximum) number of decimals in a possibly numeric vector.
Usage
numdec(x, each = FALSE, na.rm = TRUE, maxdec = 15)
Arguments
x |
A vector of values |
each |
Logical, return the result for each value in the vector |
na.rm |
Logical, ignore missing values |
maxdec |
Maximal number of decimals to count |
Author(s)
Adrian Dusa
Examples
x <- c(12, 12.3, 12.34)
numdec(x) # 2
numdec(x, each = TRUE) # 0, 1, 2
x <- c("-.1", " 2.75 ", "12", "B", NA)
numdec(x) # 2
numdec(x, each = TRUE) # 1, 2, 0, NA, NA
[Package admisc version 0.35 Index]