Thanks a lot! But DF[c(4,6)] <- DF[c(6,4)] seems to just exchange the data, not the names. If exchanging the columns(both data and names) needs two steps? DF[c(4,6)] <- DF[c(6,4)] names(DF)[c(4,6)] <- names(DF)[c(6,4)] Shengzhe