[R] duplicated names and values

John Kane jrkrideau at yahoo.ca
Fri Sep 21 23:57:09 CEST 2007


I was afraid of that.  

I am a newbie at R and while there probably is some
easy way to do this I don't see it

This example will, at least, show you a way to get the
actual duplicate names. However I don't see any easy
way without all kinds of subsetting to get what you
need.

nas  <- c("A",  "B" , "B" ,"C" ,"B", "A" )
nums  <- c(3, 2,  1, 1, 2, 3)
names(nums)  <-  nas
nums
dups  <-  duplicated(names(nums))
mydata  <- data.frame(nas , nums, dups)
mydups  <- unique(subset(mydata[,1],   
mydata$dups=="TRUE"))


--- "Glazko, Galina"
<Galina_Glazko at URMC.Rochester.edu> wrote:

> John,
>  
> one name can have multiple values, and different
> names can have the same single value, 
> I only need to eliminate cases when the same names
> have same values...
> unique gives me really 'unique' set, whithout
> duplicates
>  
> thank you!
> best regards
> Galina
>  
> 
> ________________________________
> 
> From: John Kane [mailto:jrkrideau at yahoo.ca]
> Sent: Fri 9/21/2007 4:34 PM
> To: Glazko, Galina; r-help at stat.math.ethz.ch
> Subject: Re: [R] duplicated names and values
> 
> 
> 
> Galina,
> It is not clear to me.  Are the names and the values
> always the same or are there different values for
> some
> of the names
>  Example same name & same value
>   A  B  B C B A
>   3   2 2 1 2 3
> 
> or same names but different values
>   A  B  B C B A
>   3  2  1 1 2 3
> 
> 
> 
> --- "Glazko, Galina"
> <Galina_Glazko at urmc.rochester.edu> wrote:
> 
> > Dear list,
> >
> > 
> >
> > I am sorry about this simple question, but somehow
> I
> > can not figure out
> > how to solve my problem, may be you could help?
> >
> > I have a vector mir3:
> >
> > > length(mir3)
> >
> > [1] 220671
> >
> > 
> >
> > >head(mir3)
> >
> >          rno-miR-30c          rno-miR-30c        
> > rno-miR-30d
> > rno-miR-30e          "ENSRNOT00000049288"  
> > "ENSRNOT00000049288"
> > "ENSRNOT00000049288"    "ENSRNOT00000049288"
> >
> >          rno-miR-145          rno-miR-145        
> > rno-miR-379
> >
> > "ENSRNOT00000049288" "ENSRNOT00000049288"
> > "ENSRNOT00000061859" ....
> >
> > 
> >
> > The names there (such as
> > "rno-miR-30c","rno-miR-30d"...) can be
> > duplicated, as well as the values (e.g
> > "ENSRNOT00000049288")
> >
> > I need the vector were unique names have always
> > different values.
> >
> > That is, all entries like:
> >
> > rno-miR-30c          rno-miR-30c         
> >
> > "ENSRNOT00000049288"    "ENSRNOT00000049288"
> >
> > I have to change into single entry:
> >
> > rno-miR-30c         
> >
> > "ENSRNOT00000049288"
> >
> > ..
> >
> > 
> >
> > Thank you!
> >
> > Best regards
> >
> > Galina
> >
> > 
> >
> > 
> >
> > 
> >
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained,
> > reproducible code.
> >
> 
> 
> 
>       Be smarter than spam. See how smart SpamGuard
> is at giving junk email the boot with the All-new

> http://mrd.mail.yahoo.com/try_beta?.intl=ca
> 
> 
> 
>



More information about the R-help mailing list