Learn R Programming

radiant.data (version 1.4.5)

as_numeric: Convert variable to numeric avoiding potential issues with factors

Description

Convert variable to numeric avoiding potential issues with factors

Usage

as_numeric(x)

Value

Numeric

Arguments

x

Input variable

Examples

Run this code
as_numeric(rnorm(10))
as_numeric(letters)
as_numeric(as.factor(5:10))
as.numeric(as.factor(5:10))
as_numeric(c("a","b"))
as_numeric(c("3","4"))
as_numeric(as.factor(c("3","4")))

Run the code above in your browser using DataLab