Hi,All. How to make a program to delete repeated value? a example> c[1] 4 3 0 3 4 1 0 1 4 4 3 4 3 4 I want to get : 4 3 0 3 4 1 0 1 4 3 4 3 4 two 4 is being represented by one 4. Thanks. Tammy _________________________________________________________________ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ [[alternative HTML version deleted]]
try this: x <- c(4, 3, 0, 3, 4, 1, 0, 1, 4, 4, 3, 4, 3, 4) rle(x)$values I hope it helps. Best, Dimitris Tammy Ma wrote:> Hi,All. > > How to make a program to delete repeated value? > > a example > >> c > [1] 4 3 0 3 4 1 0 1 4 4 3 4 3 4 > > I want to get : 4 3 0 3 4 1 0 1 4 3 4 3 4 > > two 4 is being represented by one 4. > > Thanks. > > Tammy > > _________________________________________________________________ > More than messages?check out the rest of the Windows Live?. > http://www.microsoft.com/windows/windowslive/ > [[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 University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014
On 3/11/2009 5:08 AM, Tammy Ma wrote:> Hi,All. > > How to make a program to delete repeated value? > > a example > >> c > [1] 4 3 0 3 4 1 0 1 4 4 3 4 3 4 > > I want to get : 4 3 0 3 4 1 0 1 4 3 4 3 4 > > two 4 is being represented by one 4.x <- c(4, 3, 0, 3, 4, 1, 0, 1, 4, 4, 3, 4, 3, 4) rle(x)$values [1] 4 3 0 3 4 1 0 1 4 3 4 3 4 ?rle> Thanks. > > Tammy > > _________________________________________________________________ > More than messages?check out the rest of the Windows Live?. > http://www.microsoft.com/windows/windowslive/ > [[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.-- Chuck Cleland, Ph.D. NDRI, Inc. (www.ndri.org) 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894