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

Jan Schelling (schelling@ivuk.mavt.ethz.ch)
Wed, 15 Apr 1998 08:42:44 +0200


Oops, in my earlier post I certainly intendet to write:

n <- 100000 # not 1000000
z <- complex(real = round(rnorm(n),1), imaginary =round(rnorm(n),1)) # z
not z_c !!
names(z) <- paste("z", match(z ,z ), sep="")

A vector with 1000'000 elements is definitely to large to handle (at least
on my computer)

Sorry

Jan

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