Description Usage Arguments Author(s) Examples
str_to_numeric
lets you extract numbers from strings and convert them
to a numeric vector. If a single element in the character vector contains multiple
numbers, you can specify an aggregate function. See examples.
1 | str_to_numeric(x, FUN = mean, ...)
|
x |
A character vector. |
FUN |
If a string contains several numbers, you can specify an aggregate
function. By default this function returns the mean of all numbers, but you can use
|
... |
Arguments passed to |
Kristian D. Olsen
1 2 3 4 5 | x <- c("10", "between 0 and 10", "about 8,5")
y <- str_to_numeric(x, FUN = mean)
identical(y, c(10, 5, 8.5))
y <- str_to_numeric(x, FUN = head, n = 1L)
identical(y, c(10, 0, 8.5))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.