Created
August 7, 2013 23:04
-
-
Save walkerjeffd/6179788 to your computer and use it in GitHub Desktop.
R function to test is vector of datetimes is regular and continuous
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
is.regular <- function(x) { | |
# returns TRUE if vector x of POSIXct datetimes is continuous and regular | |
# by checking if there are more than one unique difftime between each row | |
x.difftime <- difftime(x[2:length(x)], x[1:(length(x)-1)], units='secs') | |
if (length(levels(factor(x.difftime))) > 1) { | |
return (FALSE) | |
} else { | |
return (TRUE) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment