r factors to numeric code example
Example 1: R factors as numeric
as.numeric(levels(f))[f] # f being the factor column
Example 2: r dataframe convert factor to numeric
breast[,'class'] <- as.numeric(as.character(breast[,'class']))
as.numeric(levels(f))[f] # f being the factor column
breast[,'class'] <- as.numeric(as.character(breast[,'class']))