Thanks Igor,
I meant if there is a tool on R (or a command you might be aware of) that can sort out the rows automatically. Not how to do it manually using a database. Fairly new to R and programming here so a less obtuse answer would be greately appreciated. Or the actual R code. Thanks again.