Created
October 5, 2012 13:41
-
-
Save RyanHope/3839862 to your computer and use it in GitHub Desktop.
Find the indices of a vector where the data changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changes <- function(x) { | |
r <- rle(x)$lengths | |
c(0,cumsum(r[1:length(r)-1]))+1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment