R: merging accounting records from two databases