Skip to content
Prev 199632 / 398503 Next

ordered factor and unordered factor

Mostly it is a conceptual difference.  An unordered factor is one where there is no inherent order to the levels, examples:

Color of car
Race
Nationality
Sex
State/Country of birth
Etc.

In the above, the order of the levels could be changed without it really changing the meaning (think of the order of bars in a bar chart).  We may want to print/plot in some specific order such as alphabetic for easy lookup or based on the summary values of another vector for nice looking plots, but there is no overriding reason why we would order color as blue/green/red vs. green/red/blue, etc.

Ordered factors have some natural order, for example maybe you are studying a drug and have doses labeled as Low, Medium, and High.  It makes the most sense to print and plot in that order rather than alphabetically (High, Low, Medium).  Any continuous variable that has been cut into categories (best not to do this, but if done) has a natural order.  Survey questions where you response can range from strongly disagree to strongly agree are usually ordered (but there may be disagreement on what the correct ordering is).

In R the most apparent effects of using ordered vs. factor is in how they print out and how some modeling functions default to handling them (the default contrasts for ordered factors is different, rpart treats ordered factors differently).

Hope this helps,