Re: [Rd] duplicates() function

2011-04-12 Thread Petr Savicky
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 murdoch.dun...@gmail.com wrote: On 08/04/2011 11:08 AM, Joshua Ulrich wrote: How about: y- rep(NA,length(x))

Re: [Rd] duplicates() function

2011-04-11 Thread B77S
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

Re: [Rd] duplicates() function

2011-04-11 Thread Uwe Ligges
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

Re: [Rd] duplicates() function

2011-04-11 Thread Duncan Murdoch
On 08/04/2011 11:39 AM, Joshua Ulrich wrote: On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch murdoch.dun...@gmail.com 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.

Re: [Rd] duplicates() function

2011-04-09 Thread Petr Savicky
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

Re: [Rd] duplicates() function

2011-04-08 Thread Joshua Ulrich
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 murdoch.dun...@gmail.com wrote: I need a function which is similar to duplicated(), but instead of returning

Re: [Rd] duplicates() function

2011-04-08 Thread Hadley Wickham
On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch murdoch.dun...@gmail.com 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

Re: [Rd] duplicates() function

2011-04-08 Thread Kasper Daniel Hansen
On Fri, Apr 8, 2011 at 11:08 AM, Joshua Ulrich josh.m.ulr...@gmail.com 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

Re: [Rd] duplicates() function

2011-04-08 Thread Joshua Ulrich
On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch murdoch.dun...@gmail.com 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

Re: [Rd] duplicates() function

2011-04-08 Thread William Dunlap
-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 08/04/2011 11:08 AM, Joshua