Re: [R] duplicated function

2014-11-18 Thread Martin Maechler
> Duncan Murdoch > on Tue, 18 Nov 2014 10:40:16 -0500 writes: > On 18/11/2014 10:23 AM, Dennis Fisher wrote: >> R 3.1.1 >> OS X >> >> Colleagues >> >> When I use the duplicated function, I often need to find both the duplicates and the original element t

Re: [R] duplicated function

2014-11-18 Thread Duncan Murdoch
On 18/11/2014 11:22 AM, John Laing wrote: That seems straightforward enough: > x <- c(7, 7, 7, 2, 3, 2) > match(x, x) [1] 1 1 1 4 5 4 > ifelse(duplicated(x), match(x, x), 0) [1] 0 1 1 0 0 4 Nice solution! Thanks. Duncan Murdoch On Tue, Nov 18, 2014 at 10:40 AM, Duncan Murdoch wrote: > On 1

Re: [R] duplicated function

2014-11-18 Thread John Laing
That seems straightforward enough: > x <- c(7, 7, 7, 2, 3, 2) > match(x, x) [1] 1 1 1 4 5 4 > ifelse(duplicated(x), match(x, x), 0) [1] 0 1 1 0 0 4 On Tue, Nov 18, 2014 at 10:40 AM, Duncan Murdoch wrote: > On 18/11/2014 10:23 AM, Dennis Fisher wrote: >> >> R 3.1.1 >> OS X >> >> Colleagues >> >> W

Re: [R] duplicated function

2014-11-18 Thread Duncan Murdoch
On 18/11/2014 10:23 AM, Dennis Fisher wrote: R 3.1.1 OS X Colleagues When I use the duplicated function, I often need to find both the duplicates and the original element that was duplicated. This can be accomplished with: duplicated(OBJECT) | duplicated(OBJECT, fromLast=TRUE) From

[R] duplicated function

2014-11-18 Thread Dennis Fisher
R 3.1.1 OS X Colleagues When I use the duplicated function, I often need to find both the duplicates and the original element that was duplicated. This can be accomplished with: duplicated(OBJECT) | duplicated(OBJECT, fromLast=TRUE) >From my perspective, an improvement in the duplicate

Re: [R] Duplicated function with conditional statement

2013-07-28 Thread vanessa van der vaart
gt; #208 buy 5 0 > #21 8 sample 4 1 > #228 buy 2 1 > > A.K. > > > - Original Message - > From: arun > To: vanessa van der vaart > Cc: David Winsemius ; R help > > Sent: Saturday, July 27, 2013 9:11

Re: [R] Duplicated function with conditional statement

2013-07-27 Thread arun
ate and sorted these 10. unique(unlist( #unlist the list and choose only the unique elements 11. dat[unique(unlist(,newColumn]<-1 # assign those rows that fits the condition in newColumn as 1. Hope it helps. Regards, A.K.   From: vanessa

Re: [R] Duplicated function with conditional statement

2013-07-27 Thread arun
buy   2  1 A.K. - Original Message - From: arun To: vanessa van der vaart Cc: David Winsemius ; R help Sent: Saturday, July 27, 2013 9:11 PM Subject: Re: [R] Duplicated function with conditional statement HI, May be this is what you wanted. #using tt1 indx<-which(tt1$respons

Re: [R] Duplicated function with conditional statement

2013-07-27 Thread arun
, let me change the >conditional statement, I hope you can understand. i will explain by >example > >as you can see, almost every number is duplicated, but only in row 6th,7th,and >9th the value on column is 1. > >on row4th, the value is duplicated( 2 already occurred on 2nd ro

Re: [R] Duplicated function with conditional statement

2013-07-27 Thread vanessa van der vaart
hope you can understand. i will explain by > example > > as you can see, almost every number is duplicated, but only in row > 6th,7th,and 9th the value on column is 1. > > on row4th, the value is duplicated( 2 already occurred on 2nd row),but > since the value is considered as d

Re: [R] Duplicated function with conditional statement

2013-07-26 Thread arun
onse is 'buy' than the value on column, on row4th still zero.  On row 6th, where the value product column is 3. 3 is already occurred in 3rd row where the value on response is 'buy', so the value on column should be 1 I hope it can understand the conditional statement.

Re: [R] Duplicated function with conditional statement

2013-07-26 Thread David Winsemius
On Jul 26, 2013, at 2:06 PM, David Winsemius wrote: > > On Jul 26, 2013, at 11:51 AM, Uwe Ligges wrote: > >> >> >> On 25.07.2013 21:05, vanessa van der vaart wrote: >>> Hi everybody,, >>> I have a question about R function duplicated(). I have spent days try to >>> figure this out,but I cant

Re: [R] Duplicated function with conditional statement

2013-07-26 Thread David Winsemius
On Jul 26, 2013, at 11:51 AM, Uwe Ligges wrote: > > > On 25.07.2013 21:05, vanessa van der vaart wrote: >> Hi everybody,, >> I have a question about R function duplicated(). I have spent days try to >> figure this out,but I cant find any solution yet. I hope somebody can help >> me.. >> this is

Re: [R] Duplicated function with conditional statement

2013-07-26 Thread Uwe Ligges
On 25.07.2013 21:05, vanessa van der vaart wrote: Hi everybody,, I have a question about R function duplicated(). I have spent days try to figure this out,but I cant find any solution yet. I hope somebody can help me.. this is my data: subj=c(1,1,1,2,2,3,3,3,4,4) response=c('sample','sample','

[R] Duplicated function with conditional statement

2013-07-26 Thread vanessa van der vaart
Hi everybody,, I have a question about R function duplicated(). I have spent days try to figure this out,but I cant find any solution yet. I hope somebody can help me.. this is my data: subj=c(1,1,1,2,2,3,3,3,4,4) response=c('sample','sample','buy','sample','buy','sample',' sample','buy','sample',