Am just new to R, just struggling to write a function to have a final table as shown in the final table. l have a data as seen below of two different fragments