Re: [R] extracting the levels of a subset of data

2003-09-19 Thread Philipp Pagel
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 PagelTel.  +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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] extracting the levels of a subset of data

2003-09-19 Thread Jesus Frias
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

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help