Skip to content

Instantly share code, notes, and snippets.

@Ironholds
Created September 16, 2014 19:53
Show Gist options
  • Select an option

  • Save Ironholds/c81dd7dcd35c1a5560d2 to your computer and use it in GitHub Desktop.

Select an option

Save Ironholds/c81dd7dcd35c1a5560d2 to your computer and use it in GitHub Desktop.
Fer breaking inter-time events up into sessions
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