Description Usage Arguments Value Examples
This function coerces objects into a numeric vector. There are several differences between
this function and as.numeric
. First, if as.character2
fails to coerce (this is
usually because there are characters in the input object), it will raise an error and stop
rather than to give a warning. Second, it can handle data frame object, list, and recursive
list. Third, it can coerce number-like factors exactly into what users see on the screen.
1 |
... |
one or more objects to be coerced. |
a numeric vector, or, if fails, an error will be raised.
1 2 3 4 5 6 7 8 9 10 11 | # Try to coerce data frame
a <- c(55, 66, 77, 88, 66, 77, 88)
b <- factor(a)
df <- data.frame(a, b)
as.numeric2(df, a*2)
# Try a list
l <- list(a, a*2)
as.numeric2(l)
# Try a list of lists
l2 <- list(l, l)
as.numeric2(l2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.