Description Usage Arguments Details Value See Also Examples
Converting factors to numeric
1 2 3 4 5 6 7 | as_numeric(x)
## Default S3 method:
as_numeric(x)
## S3 method for class 'factor'
as_numeric(x)
|
x |
a vector |
as_numeric()
is motivated by the need to convert factors to their
numerical representation, rather than their numerically encoded levels. See
the examples for differences between base::as.numeric()
and
as_numeric
.
a numeric vector of the same length as x
in which each value
of x
is converted to its actual numeric value
as_numeric.factor
directly follows the suggestion from the
Warning
section of factor
.
1 2 3 | x <- factor(c(-1.9, 0.2, 3.5))
as.numeric(x)
as_numeric(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.