Noah Silverman wrote:
Hi, I have a dataset where the results are coded ("yes", "no") We want to do some machine learning with SVM to predict the "yes" outcome My problem is that if I just use the as.factor function to convert, then it reverses the levels. ---------------------- x <- c("no", "no", "no", "yes", "yes", "no", "no") as.factor(x) [1] no no no yes yes no no Levels: no yes
You want to use ?factor, not ?as.factor. Then you can use the "levels" argument.
factor(x, levels = c("yes", "no")) Also see ?relevel. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.