s-news
[Top] [All Lists]

Re: simple function

To: christos@nuverabio.com, "'Leeds, Mark'" <mleeds@mlp.com>, s-news@lists.biostat.wustl.edu
Subject: Re: simple function
From: "Richard M. Heiberger" <rmh@temple.edu>
Date: Sun, 12 Jun 2005 10:41:12 -0400
Cc: cspark@ces.clemson.edu
Almost.  The original query claimed that given a name, the number was
unique, it didn't claim that given a number the name was unique.
Therefore the test needs to be on the names, not the values.


x <- c(a=3, b=4, c=5, a=3, c=5, d=3)
x
x[!duplicated(names(x))]

> x <- c(a=3, b=4, c=5, a=3, c=5, d=3)
> x
 a b c a c d 
 3 4 5 3 5 3
> x[!duplicated(names(x))]
 a b c d 
 3 4 5 3
> 
> 

<Prev in Thread] Current Thread [Next in Thread>