# [S] Re: name identical elements (was: no subject)

Jan Schelling (schelling@ivuk.mavt.ethz.ch)
Wed, 15 Apr 1998 02:12:05 +0200

A quick and easy way to identify identical elements of a vector is the
function match():

Try

z_c <- complex(real = round(rnorm(1000),1), imaginary = round(rnorm(1000),1))
names(z_c) <- paste("z", match(z_c,z_c), sep="")

For 1'000'000 elements this only takes a couple of seconds on a 200 MHz
Pentium Pro PC (NT4.0, S+4.0)

Greetings

Jan

---------------------------------------------------------------
Jan Schelling
Institute of Process Engineering
ETH Zurich, 8092 Switzerland
phone: ++41-1-633 62 63
fax: ++41-1-633 11 19
email: schelling@ivuk.mavt.ethz.ch
internet: http://www.ivuk.ethz.ch/staff/Schelling/
---------------------------------------------------------------

Original message:
----------------------------
At 12:15 14.04.98 -0500, srosenfeld@nesdis.noaa.gov wrote:
>Dear S'ers:
>
>Can anybody help me in solving the following problem:
>I have a series of complex numbers z[i], i=1,....,N
>There are numerous repetitions in these numbers. For example, N is of order
>1,000,000. However, only ~20,000 of z[i] are different. I need to assign a
>unique name or number to each of z[i] in such a way that equal z have the
same
>name.
>For example, I have
>
>z_c(0+0i,1+0i,0+1i,1+1i,10+1i,0+1i,0+1i,1+1i,10-1i,0+1i,10+1i,0+1i,0+1i,1+1i)
>
>I need to name them as follows
>names(z)_c("z1","z2","z3","z4","z5","z3","z3","z4","z6","z3","z5","z3","z3"
,"z4"
>)
>
>
>In order to get the result until the end of this century, I want to avoid
>looping, and especially double looping.
>
>Thank you
>
>
>
>Simon Rosenfeld
>NOAA Science Center,
>NESDIS/Satellite Research Lab
>Camp Springs, MD
>-----------------------------------------------------------------------
>This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
>send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
>message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news