... 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
Ho to all
i get the results
mtcars[duplicated(mtcars$wt,fromLast=TRUE),]
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 15.84 0 034
Merc 280 19.2 6 167.6 123 3.92 3.44 18.30 1 044
mtcars[duplic
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
Sorry!
I try it again
Dear R Users!
I have a dataframe with duplicatecases. Var1 duplicated by var2.
var1 var2 var3 var4 var5
14 500 12
13 200 25
18 125 19
22 120 252
2622 12
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
/ablejec.nib.si
> tel: + 386 (0)59 232 789
> fax: + 386 1 241 29 80
> --
> Organizer of
> Applied Statistics 2009 conference
> http://conferences.nib.si/AS2009
>
>
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r
y 14, 2009 8:17 AM
> To: r-help@r-project.org
> Subject: [R] Duplicates and duplicated
>
> 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)
&
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] [,
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] [,8] [,9] [,10]
x123445678 9
y0
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
Dear list,
I have a data frame of survey respondents, a little like this:
set.seed(20081215)
n <- 100
dat <- data.frame(id=1:100,
addr1=sample(LETTERS, n, replace=TRUE),
addr2=sample(LETTERS, n, replace=TRUE),
addr3=sample(LETTERS, n, replace
20 matches
Mail list logo