Hi,> tmpdata<-subset(myd, TYPE=="A") > levels(tmpdata$TYPE) > [1] "A" "B" "C"I'd like to get only "A" as output... Thanks for your help Marc
Hi!> > tmpdata<-subset(myd, TYPE=="A") > > levels(tmpdata$TYPE) > > [1] "A" "B" "C" > > I'd like to get only "A" as output...rebuild the factor after subsetting: tmpdata$TYPE <- factor(tmp$TYPE) If you want the levels of all factors in your data frame to be adjusted you could also use: tmpdata <- data.frame(as.matrix( subset(myd, TYPE=='A') )) cu Philipp -- Dr. Philipp Pagel Tel. +49-89-3187-3675 Institute for Bioinformatics / MIPS Fax. +49-89-3187-3585 GSF - National Research Center for Environment and Health Ingolstaedter Landstrasse 1 85764 Neuherberg, Germany
Hiya> I'd like to get only "A" as output...two solutions: 1.-use unique() unique(tempdata$TYPE) to get your answer 2.-or call factor again to reduce the levels:> tmpd <- subset(myd,clas=="A") > levels(tmpd$clas)[1] "A" "B" "C"> tmpd$clas <- factor(tmpd$clas) > levels(tmpd$clas)[1] "A" regards, IOsu -- This message has been scanned for content and viruses by the DIT ICT Services MailScanner Service, and is believed to be clean. http://www.dit.ie