Skip to content

Instantly share code, notes, and snippets.

@kdiverson
Created July 14, 2015 12:44
Show Gist options
  • Save kdiverson/460d31aecadf3e8f5d92 to your computer and use it in GitHub Desktop.
Save kdiverson/460d31aecadf3e8f5d92 to your computer and use it in GitHub Desktop.
multimerge
multmerge = function(mypath){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.delim(file=x,header=T)})
}
multmerge = function(mypath){
filenames=list.files(path=mypath, full.names=TRUE)
datalist = lapply(filenames, function(x){read.table(pipe("cut -f1,2,3,4,5,6 myFile.txt"))})
Reduce(function(x,y) {merge(x,y)}, datalist)
}
mkdir trimed && for i in *.species; do cut -f1,2,3,4,5,6 $i > trimmed/$i.trimmed; done;
mymergeddata = multmerge("trimmed")
library("plyr")
df<-rbind.fill(mymergeddata)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment