s-news
[Top] [All Lists]

Re: factor levels

To: yiwu ye <yiwu21111958@yahoo.com>
Subject: Re: factor levels
From: David L Lorenz <lorenz@usgs.gov>
Date: Fri, 19 Jan 2007 07:30:20 -0600
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <20070119003842.30907.qmail@web57105.mail.re3.yahoo.com>

Yiwu,
  I think that you want the new object x to have only 4 levels rather than having a function that reports only the levels that are used. In S-PLUS the former is easy:
x <- x[-4, drop=T]
 
Dave


yiwu ye <yiwu21111958@yahoo.com>
Sent by: s-news-owner@lists.biostat.wustl.edu

01/18/2007 06:38 PM

To
s-news@lists.biostat.wustl.edu
cc
Subject
[S] factor levels





Dear list,

I have the following problem. Could anyone help?

x_as.factor(letters[1:5])
x_x[-4]
levels(x)
The levels(x) still gives you 5 rather than 4 levels. Of course, I can do levels(as.factor(as.character(x)) to  get rid of the non-existing factor level. But, I think there must be a simpler way.

Thanks

Yiwu



No need to miss a message. Get email on-the-go
with Yahoo! Mail for Mobile.
Get started.
<Prev in Thread] Current Thread [Next in Thread>