View source: R/types.castNumber.R
types.castNumber | R Documentation |
Cast numbers of any kind including decimals.
types.castNumber( format, value, options = { } )
format |
no options (other than the default) |
value |
number to cast |
options |
available options are "decimalChar", "groupChar" and "bareNumber", where
|
The lexical formatting follows that of decimal in XMLSchema: a non-empty finite-length sequence of decimal digits separated by a period as a decimal indicator. An optional leading sign is allowed. If the sign is omitted, "+" is assumed. Leading and trailing zeroes are optional. If the fractional part is zero, the period and following zero(es) can be omitted. For example: '-1.23', '12678967.543233', '+100000.00', '210'.
The following special string values are permitted (case need not be respected):
NaN
: not a number
INF
: positive infinity
-INF
: negative infinity
A number MAY also have a trailing:
exponent
: this MUST
consist of an E followed by an optional + or - sign followed by one or more decimal digits (0-9)
Types and formats specifications
types.castNumber(format = "default", value = 1) types.castNumber(format = "default", value = "1.0") # cast number with percent sign types.castNumber(format = "default", value = "10.5%", options = list(bareNumber = FALSE)) # cast number with comma group character types.castNumber(format = "default", value = "1,000", options = list(groupChar = ',')) types.castNumber(format = "default", value = "10,000.50", options = list(groupChar = ',')) # cast number with "#" group character and "&" as decimal character types.castNumber(format = "default", value = "10#000&50", options = list(groupChar = '#', decimalChar = '&'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.