Re: [R] drop unused levels in sqldf

2008-08-29 Thread glaporta
Thanx guys, practical and effective solutions. Gianandrea glaporta wrote: Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop function, but without success. Do you have any suggestions? Thanx, Gianandrea

[R] drop unused levels in sqldf

2008-08-28 Thread glaporta
Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop function, but without success. Do you have any suggestions? Thanx, Gianandrea data(iris) require(sqldf) base-sqldf(select * from iris where Species 'setosa') str(base)

Re: [R] drop unused levels in sqldf

2008-08-28 Thread David Hajage
If you want to suppress the unused level of Species, you can use factor() : table(base$Species) table(factor(base$Species)) 2008/8/28 glaporta [EMAIL PROTECTED] Hi, sqldf is a fantastic package, but when the SELECT procedure runs unused levels remain in the output. I tried with the drop

Re: [R] drop unused levels in sqldf

2008-08-28 Thread Gabor Grothendieck
Here are two approaches: 1. rename the column to circumvent the column classing heuristic. In the following Species will be a 3-level factor and Species2 will be a 2-level factor sqldf(select *, Species as Species2 from iris where Species 'setosa') 2. use method = raw. This code below