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,
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
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
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
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
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]
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
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) =
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
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]]
_
10 matches
Mail list logo