Can someone explain why levels() shows three factor levels, while you can see that the vector has only two?
> str(walk.df)
'data.frame': 10 obs. of 4 variables:
$ walker : Factor w/ 3 levels "1","2","3": 1 1 1 1 1 2 2 2 2 2
> walk.df$walker
[1] 1 1 1 1 1 2 2 2 2 2
Levels: 1 2 3
I would like to extract a vector of levels, and I thought this was the proper way, but as you can see, a three sneaks in there which is messing up my function.
> as.numeric(levels(walk.df$walker))
[1] 1 2 3