For a list say; list1<-{1,2,3,4,5,2,1} How do I remove the duplicates please? My real list is 20,000 obs long of dates with many duplicates Regards Glenn [[alternative HTML version deleted]]
?unique unique(list1) ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von glenn Gesendet: Wednesday, January 14, 2009 8:20 AM An: r-help at r-project.org Betreff: [R] Removing duplicates from a list For a list say; list1<-{1,2,3,4,5,2,1} How do I remove the duplicates please? My real list is 20,000 obs long of dates with many duplicates Regards Glenn [[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.
have a look at ?unique(), e.g., unique(c(1,2,3,4,5,2,1)) I hope it helps. Best, Dimitris glenn wrote:> For a list say; > > list1<-{1,2,3,4,5,2,1} > > How do I remove the duplicates please? > My real list is 20,000 obs long of dates with many duplicates > > Regards > > Glenn > > [[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. >-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
Try this: unique(list1) On Wed, Jan 14, 2009 at 11:19 AM, glenn <g1enn.roberts@btinternet.com>wrote:> For a list say; > > list1<-{1,2,3,4,5,2,1} > > How do I remove the duplicates please? > My real list is 20,000 obs long of dates with many duplicates > > Regards > > Glenn > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Your dummy data is not a reproducible example. I'm guessing ?unique could help you. Hope this helps, baptiste On 14 Jan 2009, at 13:19, glenn wrote:> For a list say; > > list1<-{1,2,3,4,5,2,1} > > How do I remove the duplicates please? > My real list is 20,000 obs long of dates with many duplicates > > Regards > > Glenn > > [[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._____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
On 14/01/2009 8:19 AM, glenn wrote:> For a list say; > > list1<-{1,2,3,4,5,2,1} > > How do I remove the duplicates please? > My real list is 20,000 obs long of dates with many duplicatesSee ?unique. Duncan Murdoch
On Wed, Jan 14, 2009 at 2:19 PM, glenn <g1enn.roberts at btinternet.com> wrote:> For a list say; > > list1<-{1,2,3,4,5,2,1}You mean list1 <- list(1,2,3,4,5,2,1) ?? See ?unique Gabor> > How do I remove the duplicates please? > My real list is 20,000 obs long of dates with many duplicates > > Regards > > Glenn > > [[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. >-- Gabor Csardi <Gabor.Csardi at unil.ch> UNIL DGM