c_to_n | R Documentation |
Extract numeric values from character values
c_to_n(x, ...)
## S3 method for class 'character'
c_to_n(
x,
...,
pattern_numeric = paste0("^[+-]?",
"(?:[0-9]+|[0-9]+\\.|\\.[0-9]+|[0-9]+\\.[0-9]+)", "(?:[eE][+-]?[0-9]+)?$"),
verbose = TRUE
)
## S3 method for class 'factor'
c_to_n(x, ...)
## S3 method for class 'numeric'
c_to_n(x, ...)
## S3 method for class 'integer'
c_to_n(x, ...)
## S3 method for class 'logical'
c_to_n(x, ...)
## S3 method for class 'data.frame'
c_to_n(x, ..., verbose = TRUE)
x |
An object to convert from character to numeric using SDTM or ADaM rules. |
... |
Passed to other 'c_to_n()' methods |
pattern_numeric |
A regular expression to detect numeric values. |
verbose |
Report detailed status of . |
The main workhorse function is c_to_n.character, and it will recognize the following numeric types:
positive or negative (with optional sign) for all classes
integers with an optional decimal point after the number
floating point numbers without a number before the decimal point
floating point numbers with a number before or after the decimal point
scientific notation with any of the prior numeric types as the coefficient and an optional sign before the exponent
Spaces at the beginning and end are removed with 'trimws()'
For vectors, a numeric vector with 'NA' at locations with non-numeric values. For data.frames and similar, the same class of object with numeric versions of columns added.
c_to_n(character)
: The main workhorse function of c_to_n
c_to_n(factor)
: For factors.
c_to_n(numeric)
: For numeric vectors.
c_to_n(integer)
: For integer vectors.
c_to_n(logical)
: For logical vectors (only handles all-NA case).
c_to_n(data.frame)
: For data.frames and similar, finds columns matching the
regular expression pattern '"^..(ST|OR).*C$"'. data.frame method does not
replace numeric columns that already exist.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.