How do I merge cells in the same column in columns 1 to 4 on the condition that cells in columns 1 and 2 are identical? The before is an output after a one-to-many merge. The after is the desired final output.


How do I merge cells in the same column in columns 1 to 4 on the condition that cells in columns 1 and 2 are identical? The before is an output after a one-to-many merge. The after is the desired final output.


Check out FlexTable in the ReporteRs package. It has a spanFlexTableRowsfunction that does exactly what you're looking for.
Help page here: http://davidgohel.github.io/ReporteRs/articles/FlexTable.html
Admittedly, this is only for presentation of the data, not for working with it.