Suppose I have a data.frame like:
set.seed(123)
df <- data.frame(a=rnorm(10, 0,1), b=rnorm(10,1,2), c=rnorm(10, 2, 1),
x=rnorm(10, 1,2), y=rnorm(10,2,3), z=rnorm(10, 3, 4))
# a b c x y z
#1 -0.56047565 3.44816359 0.9321763 1.8529284 -0.08412094 4.013274
#2 -0.23017749 1.71962765 1.7820251 0.4098570 1.37624817 2.885813
#3 1.55870831 1.80154290 0.9739956 2.7902513 -1.79618905 2.828518
#4 0.07050839 1.22136543 1.2711088 2.7562670 8.50686790 8.474409
#5 0.12928774 -0.11168227 1.3749607 2.6431622 5.62388599 2.096916
#6 1.71506499 4.57382627 0.3133067 2.3772805 -1.36932575 9.065882
#7 0.46091621 1.99570096 2.8377870 2.1078353 0.79134549 -3.195011
#8 -1.26506123 -2.93323431 2.1533731 0.8761766 0.60003394 5.338455
#9 -0.68685285 2.40271180 0.8618631 0.3880747 4.33989536 3.495417
#10 -0.44566197 0.05441718 3.2538149 0.2390580 1.74989280 3.863766
How can I reorder the columns to get the following?
# a x b y c z
#1 -0.56047565 1.8529284 3.44816359 -0.08412094 0.9321763 4.013274
#2 -0.23017749 0.4098570 1.71962765 1.37624817 1.7820251 2.885813
#3 1.55870831 2.7902513 1.80154290 -1.79618905 0.9739956 2.828518
#4 0.07050839 2.7562670 1.22136543 8.50686790 1.2711088 8.474409
#5 0.12928774 2.6431622 -0.11168227 5.62388599 1.3749607 2.096916
#6 1.71506499 2.3772805 4.57382627 -1.36932575 0.3133067 9.065882
#7 0.46091621 2.1078353 1.99570096 0.79134549 2.8377870 -3.195011
#8 -1.26506123 0.8761766 -2.93323431 0.60003394 2.1533731 5.338455
#9 -0.68685285 0.3880747 2.40271180 4.33989536 0.8618631 3.495417
#10 -0.44566197 0.2390580 0.05441718 1.74989280 3.2538149 3.863766