[R] keep only the first value of a numeric sequence
jeff6868
geoffrey_klein at etu.u-bourgogne.fr
Mon Dec 15 11:33:24 CET 2014
Hello dear R-helpers,
I have a small problem in my algorithm. I have sequences of "0" and "1"
values in a column of a huge data frame, and I just would like to keep the
first value of each sequences of "1" values, such like in this example:
data <-
data.frame(mydata=c(0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,1,1),final_wished_data=c(0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0))
Any easy way to do this?
Thanks everybody!
--
View this message in context: http://r.789695.n4.nabble.com/keep-only-the-first-value-of-a-numeric-sequence-tp4700774.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list