Skip to content

Instantly share code, notes, and snippets.

@mmgaggle
Created April 7, 2016 07:52
Show Gist options
  • Save mmgaggle/aa91665d5f5fac0442c4497b8189557c to your computer and use it in GitHub Desktop.
Save mmgaggle/aa91665d5f5fac0442c4497b8189557c to your computer and use it in GitHub Desktop.
#!/usr/local/bin/Rscript
library(zoo)
multmerge = function(mypath){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.zoo(file=x,sep=',',header=T)})
Reduce(function(x,y) {merge(x,y)}, datalist)
}
merge = multmerge("merge/merge")
write.zoo(merge, file = 'merge.csv', sep =',', na='=NA()')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment