Re: [R] Bug in levels() function?

2008-01-29 Thread Groot, Philip de
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

Re: [R] Bug in levels() function?

2008-01-28 Thread Peter Dalgaard
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

[R] Bug in levels() function?

2008-01-28 Thread Groot, Philip de
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

Re: [R] Bug in levels() function?

2008-01-28 Thread hadley wickham
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

Re: [R] Bug in levels() function?

2008-01-28 Thread Thomas Lumley
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