Let us say I have two relatively large tab-delimited files file1.txt, file2.txt.
file1.txt
id\tcity\tcar\ttype\tmodel
file2.txt
id\tname\trating
Let us suppose that file1.txt has 2000 unique ids, and therefore 2000 unique rows, and file2.txt has only 1000 unique rows, and therefore 1000 unique ids. Is there a way to merge the two tables?
Case 1. merge them by id in file1.txt, where when there is no id in file2.txt NAs would be filled in.
Case2. merge them by id in file2.txt, where when only the ids in file2.txt will be printed out with the fields in file1.txt and file2.txt.
Note: the merged new files should also be tab-delimited file, with a header file as well. Note2. I'd also appreciate suggestions on how to do it when there is no header as well.
Thanks!