Re: [R] Including only a subset of the levels of a factor XXXX

2011-09-02 Thread peter dalgaard
On Sep 1, 2011, at 21:11 , R. Michael Weylandt wrote: Dropping all occurences of a factor does not drop that level. This actually turns out to be much more useful than it first might appear, but if you really need to get around it, it can be done. ...most expediently by using factor(), as

[R] Including only a subset of the levels of a factor XXXX

2011-09-01 Thread Dan Abner
Hello everyone, I have the following factor: levels(pp_income) [1]1 2 3 4 5 6 7 [9] 8 9 Renter I want to subset so that only values 1:9 are included. I have the following: income-pp_income[pp_income %in% c(1:9)] levels(income) [1]1

Re: [R] Including only a subset of the levels of a factor XXXX

2011-09-01 Thread R. Michael Weylandt
Dropping all occurences of a factor does not drop that level. This actually turns out to be much more useful than it first might appear, but if you really need to get around it, it can be done. Look at this toy example: R x = factor(c(A,B,C,A,B,C,C)) R x [1] A B C A B C C Levels: A B C R x[x !=

Re: [R] Including only a subset of the levels of a factor XXXX

2011-09-01 Thread David Winsemius
On Sep 1, 2011, at 2:59 PM, Dan Abner wrote: Hello everyone, I have the following factor: levels(pp_income) [1]1 2 3 4 5 6 7 [9] 8 9 Renter I want to subset so that only values 1:9 are included. I have the following: