I have a huge data that I cannot upload here because.
I have two types of columns, their names start with T.H.L or T.H.L.varies..... Both types have are numbered in the format So####, e.g., T.H.L.So1_P1_A2 until T.H.L.So10000_P1_A2.
For each T.H.L column there is a column named T.H.L.varies.... with the same ending.
I want to order the columns by the numbers after So, with first the T.H.L and then the corresponding T.H.L.varies.... version for each So number.
What I tried was to do
library(gtools)
mySorted<- df2[,mixedorder(colnames(df2))]
Which is close, it sorts them correctly by number, but first all T.H.L and then all T.H.L.varies instead of alternating them.
I have posted the column names to Github:
dput(names(df)), or maybedput(names(df)[1:100])if the first is too long.df2 = df[, grep(pattern = "^T\\.H\\.L\\.", x = names(df))]... it might be what you want. If that's not what you want, maybe you can clarify, the sentence "Means I want one T.H.L and one T.H.L.varies which both have the same end" doesn't make sense to me.Soin the column name?