Skip to content

Instantly share code, notes, and snippets.

@mmgaggle
Created April 8, 2016 17:45
Show Gist options
  • Save mmgaggle/0437895ca3734f788e323158020966b1 to your computer and use it in GitHub Desktop.
Save mmgaggle/0437895ca3734f788e323158020966b1 to your computer and use it in GitHub Desktop.
#!/usr/local/bin/Rscript
filenames <- list.files("./",pattern="output*",full.names=TRUE)
files <- lapply(filenames, function(filename){ read.csv(file=filename,sep=';',stringsAsFactors=FALSE,skip=4) })
post_ramp_subsets <- lapply(files, function(file) { subset(file,file[50]>=60000) })
results <- lapply(post_ramp_subsets, function(thread_subset) {
threads <- unique(thread_subset[,3])
thread_subsets <- lapply(threads, function(thread){ subset(thread_subset,thread_subset[,3]==thread) })
means <- lapply(thread_subsets, function(thread_subset){ mean(thread_subset[,49]) })
thread_sum <- Reduce("+",means)
})
Reduce("+",Filter(Negate(is.null),results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment