On Wed, Sep 23, 2009 at 07:29:30AM -0500, Peng Yu wrote: > On Wed, Sep 23, 2009 at 1:24 AM, Peter Dalgaard > <p.dalga...@biostat.ku.dk> wrote: > > Peng Yu wrote: > > Is there an operation on a factor to get a subset and keep only the > corresponding levels (see commented line below)?
Yes, there is: call factor() on your subset: > a <- factor(rep(letters[1:5], 5)) > a [1] a b c d e a b c d e a b c d e a b c d e a b c d e Levels: a b c d e > b <- a[a!='b'] > b [1] a c d e a c d e a c d e a c d e a c d e Levels: a b c d e > factor(b) [1] a c d e a c d e a c d e a c d e a c d e Levels: a c d e cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.