Message-ID: <1100897271.31008.38.camel@horizons.localdomain>
Date: 2004-11-19T20:47:51Z
From: Marc Schwartz
Subject: Selecting distinct values from a column
In-Reply-To: <BAY2-F341F4B36FA4DBEF5313417B5C30@phx.gbl>
On Fri, 2004-11-19 at 19:01 +0000, Ann Huxtable wrote:
> Hello,
>
> Is there an easy way (other than the obvious for loop?) to select distinct
> values from a column vector?
>
> Many thanks
>
> Ann
Presuming that by 'distinct' you mean 'unique', see ?unique
> MyVec <- rep(1:5, times = c(1:5))
> MyVec
[1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
> unique(MyVec)
[1] 1 2 3 4 5
HTH,
Marc Schwartz