I have a dataframe in R with the following row-structure
rowA1
rowA2
rowA3
rowB1
rowB2
rowB3
rowC1
rowC2
rowC3
I want to reorder it that way:
rowA1
rowB1
rowC1
rowA2
rowB2
rowC2
rowA3
rowB3
rowC3
how?
edit: to clarify, the dataframe originally is composed out of 3 dataframes using bind_rows(A,B,C) each dataframe had 3 items.
Note that rowA1 etc. are exemplary and could contain any columns and values.
One
dplyroption (instead ofsubstryou can usereadr::parse_numberas Jon suggested):