Use factor indeed as.factor:

factor(x, levels = c('yes', 'no'))

On Thu, Jun 17, 2010 at 4:47 PM, Noah Silverman <n...@smartmediacorp.com>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
> ----------------------
> The SVM function (in the e1071 package) sees "no" as the first label and
> treats that as the positive outcome. The problem arises when we look at
> the decision values of the
> predictions.  Everything is gauged as values for "no".
> So, is there a way to force R to use my specified order when converting
> to factors?
> I've tried as.factor(x, levels=c("yes", "no")) but that throws errors
> about unused arguments.
>
> Any help?
>
>
> Thanks
>
> ______________________________________________
> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to