Skip to content
Prev 170434 / 398503 Next

tapply bug? - levels of a factor in a data frame after tapply are intermixed

On Fri, Feb 13, 2009 at 12:24 PM, Marc Schwartz
<marc_schwartz at comcast.net> wrote:
Marc (and everyone), I expected it to show:
$ xx: Factor w/ 3 levels "3","9","15":  1 2 3
rather than what I am seeing:
$ xx: Factor w/ 3 levels "3","9","15":  2 1 3
Because 3 is level 1, 9 is level 2 and 15 is level 3.
I have several other factors in my original data frame. And I've done
that tapply for all of them (for the same dependent variable) - and in
all of them the first level was 1, the second 2, etc.
Why I am concerned about the problem? Because I am plotting the means
of the numeric variable against the levels of the factor and it's
important to me that the factor levels are correct (in the right
order)...
Dimitri