how to convert dataframe with diffrent factor levels into numeric in r code example
Example 1: r dataframe convert factor to numeric
breast$class <- as.numeric(as.character(breast$class))
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)))