PROTECTED]
Sent: Mon 28-1-2008 20:03
To: Groot, Philip de
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Bug in levels() function?
This is not a bug; it is deliberately designed this way.
There are circumstances when you want to drop levels on subsetting and
other circumstances where you don't, so
Groot, Philip de wrote:
Hello all,
I am not sure whether it actually is a bug, but it is not the behaviour I
would expect. Please consider this:
Sibships
[1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901
[6] Patient_8901 Patient_4008 Patient_4008
Hello all,
I am not sure whether it actually is a bug, but it is not the behaviour I would
expect. Please consider this:
Sibships
[1] Patient_2400 Patient_2400 Patient_345 Patient_345 Patient_8901
[6] Patient_8901 Patient_4008 Patient_4008 Patient_7991 Patient_7991
[11] Patient_8353
And subsetting a factor retains the original factor levels. To drop
unused levels, just use factor(f[index]) or f[index, drop=TRUE]. The
opposite behaviour can be even more annoying/dangerous because it leads
to empty cells dropping out of tables and bars disappearing from barplots.
Of course
This is not a bug; it is deliberately designed this way.
There are circumstances when you want to drop levels on subsetting and
other circumstances where you don't, so the default behaviour can't make
everyone happy. However, there is an option to get the behaviour you want
5 matches
Mail list logo