numdec | R Documentation |
Calculates the (maximum) number of decimals in a possibly numeric vector.
numdec(x, each = FALSE, na.rm = TRUE, maxdec = 15)
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 |
Adrian Dusa
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.