# Convert variable to numeric avoiding potential issues with factors

Source: `R/transform.R`
`as_numeric.Rd`

Convert variable to numeric avoiding potential issues with factors

    as_numeric(x)

## Arguments

x

  Input variable

## Value

Numeric

## Examples

    as_numeric(rnorm(10))
    #>  [1] -1.66539524  0.84589239 -0.14666561  1.15801832  0.47822510  0.15957457
    #>  [7] -0.42560129 -1.27584256  0.02811642 -0.40987108
    as_numeric(letters)
    #>  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    #> [26] 26
    as_numeric(as.factor(5:10))
    #> [1]  5  6  7  8  9 10
    as.numeric(as.factor(5:10))
    #> [1] 1 2 3 4 5 6
    as_numeric(c("a", "b"))
    #> [1] 1 2
    as_numeric(c("3", "4"))
    #> [1] 3 4
    as_numeric(as.factor(c("3", "4")))
    #> [1] 3 4