[R] extracting the levels of a subset of data

Jesus Frias Jesus.Frias at dit.ie
Fri Sep 19 13:16:07 CEST 2003


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




More information about the R-help mailing list