From the select() help file, I gather that the only special internal function that accepts a regular expression is matches(). You can use the regular expression....
Thanks Curtis, unfortunately I don't think this method would work for my use case.
x is dynamic from another data source so I cannot manually create the regex.
I would also like to use x to order the columns as well as I will be uniting them into a numeric vector where the order is important. I could do a named vector but still have a similar problem in ordering that vector using the prefix strings.
I'm not sure your problem is well-defined right now, so difficult to give you any practical solution. One example of the approach you can take is below:
joels - I think this is on the right track but it puts the columns in alphabetical order (and I see the mistake I made in my question to lead you on this path). The order of x is a, d, b and the output should also follow this order. I will update my post.
Thank you Misha! I was able to work with this to get a functioning solution. I only needed to concatenate the id to the front of correct_order. I was hoping there was a simpler solution to simply order by prefix but this is effective.