Q:

Factors in R - when I set the levels, one factor gets recoded to NA

I have a variable (x) with 4 levels - "Never", "1-2 times a month", "1-3 times a week" and "Everyday". When I try to order the levels using 
x <- factor (x, levels=c ("Never", "1-2 times a month", "1-3 times a week", "Everyday"))

for some reason it recodes "Everyday" to NA and comes up as 0 when I calculate. I've tried putting it as the first, or second level and it does the same thing. When I tried to make dummy data, it worked fine so I can't give an example. I used the exact same code with a Likert variable and it worked fine. 

A:

The problem was a trailing space in the original data file. The label was "Everyday ", not "Everyday". Using the unique (x) I was able to see where the problem was. I was only able to see the problem when I converted it to a character ran the unique(x) function. 

