I agree with @rexevan 's approach, with one additional caveat. Unless your data is as small as the reprex, to import the source you will need unique rownames, which your example lacks.