Skip to content
Back to formatted view

Raw Message

Message-ID: <83536658864BC243BE3C06D7E936ABD5027BABFB@xchg1.statistik.local>
Date: 2005-09-16T14:53:34Z
From: TEMPL Matthias
Subject: Replicate

x = (1,1,1,2,2,2,3,3,3,3)
unique(x)

Best,
Matthias

> Dear All,
>  
> I have a vector x = (1,1,1,2,2,2,3,3,3,3)
> I am looking for a function to return a vector containing  
> the distinct elements of x i,e y = (1,2,3)
>  
> The following code gives the desired results:
>  
> as.numeric(levels(as.factor(x)))
>  
> Is there any other elegant  way?
>  
> Thanks,
>  
> B
>  
>  
> 
> 		
> ---------------------------------
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read 
> the posting guide! http://www.R-project.org/posting-guide.html
>