On Mon, Apr 11, 2011 at 02:05:11PM -0400, Duncan Murdoch wrote:
> On 08/04/2011 11:39 AM, Joshua Ulrich wrote:
> >On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch
> > wrote:
> >> On 08/04/2011 11:08 AM, Joshua Ulrich wrote:
> >>>
> >>> How about:
> >>>
> >>> y<- rep(NA,length(x))
> >>> y[duplic
On 08/04/2011 11:39 AM, Joshua Ulrich wrote:
On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch
wrote:
> On 08/04/2011 11:08 AM, Joshua Ulrich wrote:
>>
>> How about:
>>
>> y<- rep(NA,length(x))
>> y[duplicated(x)]<- match(x[duplicated(x)] ,x)
>
> That's a nice solution for vectors. Unfortun
Thanks for your answer, but:
1. can you please cite the question? It is hard for mailing list readers
to follow now.
2. I think
which(duplicated(x))
should be simpler, faster and less confusing, if your code would be the
solution - which is not.
3. Please read the original question carefuly
which(duplicated(x)=="TRUE")
--
View this message in context:
http://r.789695.n4.nabble.com/duplicates-function-tp3436584p3437614.html
Sent from the R devel mailing list archive at Nabble.com.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/
On Fri, Apr 08, 2011 at 10:59:10AM -0400, Duncan Murdoch wrote:
> I need a function which is similar to duplicated(), but instead of
> returning TRUE/FALSE, returns indices of which element was duplicated.
> That is,
>
> > x <- c(9,7,9,3,7)
> > duplicated(x)
> [1] FALSE FALSE TRUE FALSE TRUE
>
> -Original Message-
> From: r-devel-boun...@r-project.org
> [mailto:r-devel-boun...@r-project.org] On Behalf Of Duncan Murdoch
> Sent: Friday, April 08, 2011 8:16 AM
> To: Joshua Ulrich
> Cc: R-devel@r-project.org
> Subject: Re: [Rd] duplicates() function
>
On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch
wrote:
> On 08/04/2011 11:08 AM, Joshua Ulrich wrote:
>>
>> How about:
>>
>> y<- rep(NA,length(x))
>> y[duplicated(x)]<- match(x[duplicated(x)] ,x)
>
> That's a nice solution for vectors. Unfortunately for me, I have a matrix
> (which duplicated() h
On Fri, Apr 8, 2011 at 11:08 AM, Joshua Ulrich wrote:
> How about:
>
> y <- rep(NA,length(x))
> y[duplicated(x)] <- match(x[duplicated(x)] ,x)
>
I use Joshua's trick all the time. But it might still be nice with a
C implementation.
While we are discussing duplication, I would also like to see
s
On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch wrote:
> I need a function which is similar to duplicated(), but instead of returning
> TRUE/FALSE, returns indices of which element was duplicated. That is,
>
>> x <- c(9,7,9,3,7)
>> duplicated(x)
> [1] FALSE FALSE TRUE FALSE TRUE
>
>> duplicates(x
On 08/04/2011 11:08 AM, Joshua Ulrich wrote:
How about:
y<- rep(NA,length(x))
y[duplicated(x)]<- match(x[duplicated(x)] ,x)
That's a nice solution for vectors. Unfortunately for me, I have a
matrix (which duplicated() handles by checking whole rows). So a better
example that I should have
How about:
y <- rep(NA,length(x))
y[duplicated(x)] <- match(x[duplicated(x)] ,x)
--
Joshua Ulrich | FOSS Trading: www.fosstrading.com
On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch wrote:
> I need a function which is similar to duplicated(), but instead of returning
> TRUE/FALSE, returns in
I need a function which is similar to duplicated(), but instead of
returning TRUE/FALSE, returns indices of which element was duplicated.
That is,
> x <- c(9,7,9,3,7)
> duplicated(x)
[1] FALSE FALSE TRUE FALSE TRUE
> duplicates(x)
[1] NA NA 1 NA 2
(so that I know that element 3 is a dupli
12 matches
Mail list logo