[R] Converting a Vector into a 2-level Factor
Henrique Dallazuanna
wwwhsd at gmail.com
Thu Oct 22 12:47:43 CEST 2009
Try this;
factor(vowels == "aa", labels = c("aa", "~aa"))
On Thu, Oct 22, 2009 at 4:36 AM, <ntyson at clovermail.net> wrote:
> Hello Everyone,
>
> Let's say I have a vector as follows:
>
> vowels = c("aa", "aa", "ah", "ao", "eh)
>
> I want to make a factor consisting of two levels: the things that are "aa"
> and those that are not "aa". How would I do that?
>
> I tried using factor(vowels, levels=c("aa", "~aa"), exclude=NULL), but this
> gives me '<NA>' or missing values, which is not what I want. If there is no
> way to get two levels, then how do I convert the NAs to another symbol of my
> choosing?
>
> Any suggestions are welcome.
>
> Thanks.
>
> ______________________________________________
> R-help at 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
More information about the R-help
mailing list