I have got two files large files like this in Tab-delimited format, trying to merge in R, do we need to sort the file before merging?
otu <- read.table("asv.txt", sep="\t", header=T, blank.lines.skip=F, check.names=F)
> head(otu)
ID Soil.9.S42 Soil-27.S33.L001 Soil-45.S54.L001
1 d2ec9f3b77975c0f457e4b7413b217ff 34 51 84
2 3147790f0d5a78316fb9dd64f53b9473 28 32 52
3 97aecc1f35cc1f50db507ad71dd22367 33 0 7
4 bfad6370d28182cc6304844e9bec7fb6 545 237 127
5 5fa2a987221a1d9ca416148570c18086 0 0 0
6 8e60d301122d7aa359eb6b0b00f37f62 124 143 128
> taxa <- read.table("taxonomy.txt", sep="\t", header=F ,stringsAsFactors=F,quote="")
> head(taxa)
ID V2 V3 V4
d2ec9f3b77975c0f457e4b7413b217ff Bacteria Cyanobacteria Oxyphotobacteria
3147790f0d5a78316fb9dd64f53b9473 Bacteria Proteobacteria Alphaproteobacteria
97aecc1f35cc1f50db507ad71dd22367 Bacteria Proteobacteria Gammaproteobacteria
bfad6370d28182cc6304844e9bec7fb6 Bacteria Proteobacteria Alphaproteobacteria
5fa2a987221a1d9ca416148570c18086 Bacteria Proteobacteria Alphaproteobacteria
8e60d301122d7aa359eb6b0b00f37f62 Bacteria Proteobacteria Deltaproteobacteria
Now having issue with sorting file but merge command work perfectly;
newotu <- otu[order(ID),]
Error in order(ID) : object 'ID' not found
> total <- merge(otu,taxa,by="ID")
Thanks for your help.