what efficient way reorder columns data frames hundreds thousands of columns?
the following tried , works, looking optimal function.
dput(names(df1)) dump column names , used in following step
swapped columns df1[c(col1, col3, col2,.....col99,col100)
ex names(df1) "col1" "col2" "col3".............."col99" "col100" want swap "col2" , "col3",
names(df1) "col1" "col3" "col2".............."col99" "col100"
df1 = df1[,c(1,3,2,4:100)] reorders columns according permutation c(1,3,2,4:100)
Comments
Post a Comment