Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Prof Brian Ripley
On Wed, 25 Jun 2008, Gabor Csardi wrote: Wow, that is smart, although is seems to be overkill. I guess 'duplicated' is better than O(n^2), is it really? Yes as it hashes, but the overhead on short vectors is high since it always hashes. Gabor On Wed, Jun 25, 2008 at 05:43:30PM +0100,

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
Wow, that is smart, although is seems to be overkill. I guess 'duplicated' is better than O(n^2), is it really? Gabor On Wed, Jun 25, 2008 at 05:43:30PM +0100, Prof Brian Ripley wrote: > On Wed, 25 Jun 2008, Marc Schwartz wrote: > >> on 06/25/2008 11:19 AM Daren Tan wrote: >>> >>> unique(c(1

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Grothendieck
On Wed, Jun 25, 2008 at 12:19 PM, Daren Tan <[EMAIL PROTECTED]> wrote: > > > unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get > only 2:10 (i.e. values that are unique) ? > > Try this: setdiff(x, x[duplicated(x)]) __ R-help

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Marc Schwartz
on 06/25/2008 11:44 AM Gabor Csardi wrote: I'm sorry to say, but this one is wrong, too. Maybe coffee really helps, I just had one. :) Vec <- c(20:30,20) which(table(Vec) == 1) 21 22 23 24 25 26 27 28 29 30 2 3 4 5 6 7 8 9 10 11 You would actually need the names, but that would invo

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
I'm sorry to say, but this one is wrong, too. Maybe coffee really helps, I just had one. :) > Vec <- c(20:30,20) > which(table(Vec) == 1) 21 22 23 24 25 26 27 28 29 30 2 3 4 5 6 7 8 9 10 11 You would actually need the names, but that would involve some numberic -> character -> numeric

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Prof Brian Ripley
On Wed, 25 Jun 2008, Marc Schwartz wrote: on 06/25/2008 11:19 AM Daren Tan wrote: unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get only 2:10 (i.e. values that are unique) ? The easiest might be: Vec [1] 1 2 3 4 5 6 7 8 9 10 1 Vec[table(Vec) == 1]

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Gabor Csardi
Hmmm, this is not very good: > Vec <- c(10:1,1) > Vec[ table(Vec) == 1 ] [1] 9 8 7 6 5 4 3 2 1 and these are obviously not the unique values. This one is better: Vec [ ! duplicated(Vec) & ! duplicated(Vec, fromLast=TRUE) ] Gabor On Wed, Jun 25, 2008 at 11:29:31AM -0500, Marc Schwartz wrote

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Marc Schwartz
on 06/25/2008 11:29 AM Marc Schwartz wrote: on 06/25/2008 11:19 AM Daren Tan wrote: unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get only 2:10 (i.e. values that are unique) ? The easiest might be: > Vec [1] 1 2 3 4 5 6 7 8 9 10 1 > Vec[table(Vec) =

Re: [R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Marc Schwartz
on 06/25/2008 11:19 AM Daren Tan wrote: unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get only 2:10 (i.e. values that are unique) ? The easiest might be: > Vec [1] 1 2 3 4 5 6 7 8 9 10 1 > Vec[table(Vec) == 1] [1] 2 3 4 5 6 7 8 9 10 HTH, Marc

[R] selecting values that are unique, instead of selecting unique values

2008-06-25 Thread Daren Tan
unique(c(1:10,1)) gives 1:10 (i.e. unique values), is there any method to get only 2:10 (i.e. values that are unique) ? _ Easily edit your photos like a pro with Photo Gallery. [[alternative HTML version deleted]] _