How can I reorder the columns so that I can get "pre" first followed by "post" and then alternating again? Each "pre" and "post" entry is related to a question from a survey. So for example, both the first "pre" and "post" are answers for question 1 of a survey. I want to compare the answers from "pre" and "post" and for organizational purposes, want to know how I can get the column to show pre first then pro and then alternate in that order. thanks!
How do I order the variables of a column to alternate?
344 Views Asked by rainbowbagels At
2
Fake data:
I suggest you should always encode the question number in the data so that you can order them arbitrarily throughout your analysis. Never rely on the order of rows to be meaningful and preserved when not immediately discernible in a column or combination of columns.
The additional column:
Unfortunately, one cannot use negatives in ordering strings, so the use of
matchis a quick hack:Alternatively, you can use the "radix" ordering method and supply per-column
decreasing=arguments.If you really must avoid keeping question number in there, then we can internalize the
QuestionNumberlogic into theordercall, even though it can make it a bit difficult to see what's going on.