Created
July 7, 2015 02:04
-
-
Save MattSandy/5ad2183c31727d2cd814 to your computer and use it in GitHub Desktop.
Match repeated values in a vector based on a specified interval
This file contains hidden or 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
vector <- c(10,1,0,10,0,0,10,0,0,10) | |
match_interval(vector,3)) | |
match_interval <- function (vector, interval) { | |
matches <- c() | |
for(i in 1:interval) { | |
if(sd(vector[seq(i,length(vector),interval)])==0) { | |
matches[length(matches)+1] <- vector[i] | |
} | |
} | |
return(matches) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment