[R] dataframe without repetition

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Nov 9 15:17:05 CET 2005


unique(): see its help page.  (It has a data-frame method.)

On Wed, 9 Nov 2005, Bruno Cutayar wrote:

>
>
> Hello,
> with a data.frame like this :
> > toto <-
> data.frame(id=c("id1","id1","id2","id3","id3","id3"),dpt=c("13","13","34","30","30","30"))
> > toto
>   id dpt
> 1 id1  13
> 2 id1  13
> 3 id2  34
> 4 id3  30
> 5 id3  30
> 6 id3  30
>
> what is the most efficient ways to obtain :
>   id dpt
> 1 id1  13
> 2 id2  34
> 3 id3  30
> ?
> thanks in advance for your reply
> Bruno

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list