When I try to partially reorder columns using "["
, the values are swaped but the column's names do not move. See the example below:
x = data.frame(x1 = c(1,2,3), x2 = c(2,3,4), x3 = c("e","e","e"), x4 = c("f","f","f"))
x
#x1 x2 x3 x4
#1 2 e f
#2 3 e f
#3 4 e f
x[, c(3,4)] = x[, c(4,3)]
#x1 x2 x3 x4
#1 2 f e
#2 3 f e
#3 4 f e
Any idea as to why the column's names are not moving and how to simply solve this ?