Created
September 16, 2014 19:53
-
-
Save Ironholds/c81dd7dcd35c1a5560d2 to your computer and use it in GitHub Desktop.
Fer breaking inter-time events up into sessions
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
| output_list <- list(numeric()) | |
| for(i in seq_along(x)){ | |
| if(x[i] > intertime){ | |
| if(length(output_list[[length(output_list)]]) > 0){ | |
| output_list[[(length(output_list)+1)]] <- numeric() | |
| } | |
| } else { | |
| output_list[[length(output_list)]] <- c(output_list[[length(output_list)]], x[i]) | |
| } | |
| } | |
| averager <- function(x){ | |
| x <- sum(x) + mean(x) | |
| return(x) | |
| } | |
| lapply(output_list,averager) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment