r convert factor to numeric in data frame 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
indx <- sapply(breast, is.factor)
breast[indx] <- lapply(breast[indx], function(x) as.numeric(as.character(x)))