Kathryn ?unique
and see also duplicated. > unique(c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5)) [1] -1 0 2 4 5 HTH .... Peter Alspach > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of kathie > Sent: Thursday, 9 October 2008 8:12 a.m. > To: [email protected] > Subject: [R] Re move repeated values > > > Dear R users, > > I'd like to make this data > > rem.y = c(-1,0,2,4,5) > > from > > y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5). > > That is, I need to remove repeated values. > > > Here is my code, but I don't think it is efficient. How > could I improve this? > > > #------------------------------------------------------------- > ----------- > y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) > n=length(y) > > for (i in 1:n) # removed same values in y > { > imsi = 0 > if (i==1) {rem.y = y[i]} > else {c = length(rem.y) > for (j in 1:c) { if (y[i]==rem.y[j]) imsi=1 } > if (imsi==0) rem.y = c(rem.y,y[i])} } > > rem.y > #------------------------------------------------------------- > ------------ > > > Any suggestion will be greatly appreciated. > > Regards, > > Kathryn Lord > -- > View this message in context: > http://www.nabble.com/Remove-repeated-values-tp19885503p19885503.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [email protected] 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. > The contents of this e-mail are privileged and/or confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. ______________________________________________ [email protected] 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.

