Drop factor levels in a subsetted data frame. All you should have to do is to apply factor() to your variable again after subsetting:
1 2 3 4 5 6 7 | > subdf$letters [1] a b c Levels: a b c d e subdf$letters <- factor(subdf$letters) > subdf$letters [1] a b c Levels: a b c |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.