From: Atte Tenkanen <attenka_at_utu.fi>

Date: Wed 16 Aug 2006 - 17:42:35 EST

}

Atte Tenkanen

University of Turku, Finland

R-help@stat.math.ethz.ch 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. Received on Wed Aug 16 17:53:54 2006

Date: Wed 16 Aug 2006 - 17:42:35 EST

Is there some (much) more efficient way to do this?

VECTOR=c(3,2,4,5,5,3,3,5,1,6,6);

**NEWVECTOR=VECTOR[1];
**
for(i in 1:(length(VECTOR)-1))

{

if((identical(VECTOR[i], VECTOR[i+1]))==FALSE){ NEWVECTOR=c(NEWVECTOR,VECTOR[i+1])}

}

**> VECTOR
**

[1] 3 2 4 5 5 3 3 5 1 6 6

[1] 3 2 4 5 3 5 1 6

Atte Tenkanen

University of Turku, Finland

R-help@stat.math.ethz.ch 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. Received on Wed Aug 16 17:53:54 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Wed 16 Aug 2006 - 20:21:24 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*