... Alternatively(but probably less efficient):
## the indexing logical vector
with(mtcars, wt %in% wt[duplicated(wt)] )
cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom
Hello,
Simply OR (|) both conditions.
mtcars[duplicated(mtcars$wt) | duplicated(mtcars$wt,fromLast=TRUE),]
# mpg cyl disp hp drat wt qsec vs am gear carb
#Hornet Sportabout 18.7 8 360.0 175 3.15 3.44 17.02 0 032
#Duster 36014.3 8 360.0 245 3.21 3.57 1
There is most probably a function doing exactly this, but i would give
this solution a try:
dataframe=dataframe[order(dataframe[,1],-dataframe[,2]),]
kept.rows<-which(diff(dataframe[,1])+1
new.dataframe <- dataframe[kept.rows,]
Dévaványai Agamemnón schrieb:
Sorry!
I try it again
Dear R U
O Software Inc - Spotfire Division
wdunlap tibco.com
> -Original Message-
> From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com]
> Sent: Thursday, May 14, 2009 2:47 PM
> To: William Dunlap
> Cc: Bert Gunter; christiaan pauw; r-help@r-project.org
> Subject: Re: [R] D
> -Original Message-
> From: Bert Gunter [mailto:gunter.ber...@gene.com]
> Sent: Thursday, May 14, 2009 2:31 PM
> To: William Dunlap; 'Gabor Grothendieck'; 'christiaan pauw';
> 'jim holtman'
> Cc: r-help@r-project.org
> Subject: RE: [R]
retval[which(tix!=1)]<-TRUE
> retval
> }
>
> Bill Dunlap
> TIBCO Software Inc - Spotfire Division
> wdunlap tibco.com
>
>> -Original Message-
>> From: r-help-boun...@r-project.org
>> [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
>>
ay, does it
not?
-- Bert
Bert Gunter
Genentech Nonclinical Biostatistics
-Original Message-
From: William Dunlap [mailto:wdun...@tibco.com]
Sent: Thursday, May 14, 2009 10:44 AM
To: Bert Gunter; Gabor Grothendieck; christiaan pauw
Cc: r-help@r-project.org
Subject: RE: [R] Duplicates
ision
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter
> Sent: Thursday, May 14, 2009 9:10 AM
> To: 'Gabor Grothendieck'; 'christiaan pauw'
> Cc: r-help@r-
ndieck
> Sent: Thursday, May 14, 2009 7:34 AM
> To: christiaan pauw
> Cc: r-help@r-project.org
> Subject: Re: [R] Duplicates and duplicated
>
> Noting that:
>
> > ave(x, x, FUN = length) > 1
> [1] FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
>
> tr
t: Thursday, May 14, 2009 7:34 AM
To: christiaan pauw
Cc: r-help@r-project.org
Subject: Re: [R] Duplicates and duplicated
Noting that:
> ave(x, x, FUN = length) > 1
[1] FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
try this:
> rbind(x, dup = ave(x, x, FUN = length) > 1)
Noting that:
> ave(x, x, FUN = length) > 1
[1] FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
try this:
> rbind(x, dup = ave(x, x, FUN = length) > 1)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
x 123445678 9
dup000
The operator %in% is very good! And that can be simpler like this:
x %in% x[duplicated(x)]
[1] FALSE FALSE FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
On Thu, May 14, 2009 at 4:43 PM, Andrej Blejec wrote:
> Try this
>
> x%in%x[which(y)]
>
> >From your example
>
>> x=c(1,2,3,4,4,5,6,7,8,9)
>>
Try this
x%in%x[which(y)]
>From your example
> x=c(1,2,3,4,4,5,6,7,8,9)
> y=duplicated(x)
> rbind(x,y)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
x123445678 9
y000010000 0
> which(y)
[1] 5
> x[which(y)]
[1]
On Thu, May 14, 2009 at 2:16 PM, christiaan pauw wrote:
> Hi everybody.
> I want to identify not only duplicate number but also the original number
> that has been duplicated.
> Example:
> x=c(1,2,3,4,4,5,6,7,8,9)
> y=duplicated(x)
> rbind(x,y)
>
> gives:
> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,
Andrew,
Is this what you seek?
all.addresses <- Reduce( union, dat[-1] )
who.is.here <- sapply( all.addresses,
function(x) dat$id[ rowSums(dat[ -1 ] == x ) != 0 ],
simplify=FALSE)
If not, try to give us more detail.
HTH,
Chuck
On Mon, 15 Dec 2008, Andrew C. Ward w
I think you mean duplicated *rows*, not columns, despite your subject
line.
See ?dublicated, which has a data.frame method.
On Mon, 15 Dec 2008, Andrew C. Ward wrote:
Dear list,
I have a data frame of survey respondents, a little like this:
set.seed(20081215)
n <- 100
dat <- data.frame(id=1
16 matches
Mail list logo