R : Convert categorical variables to numeric in R