[R] unique-fy colume names

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jun 16 13:01:01 CEST 2008


See ?make.unique

On Mon, 16 Jun 2008, Daren Tan wrote:

>
>
> I have a column containing duplicate entries and need to append numeric suffixes to make them unique. How ?
>
> e.g., paste("id", c(1:10,1,5,10,10), sep=".")
> [1] "id.1"  "id.2"  "id.3"  "id.4"  "id.5"  "id.6"  "id.7"  "id.8"  "id.9"[10] "id.10" "id.1"  "id.5"  "id.10" "id.10"
> I hope to get
> [1] "id.1"  "id.2"  "id.3"  "id.4"  "id.5"  "id.6"  "id.7"  "id.8"  "id.9"[10] "id.10" "id.1.1"  "id.5.1"  "id.10.1" "id.10.2"
>
> _________________________________________________________________
> [[elided Hotmail spam]]
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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