I would like to be able to move columns to some desired position based solely on the name of the columns, I would like to move a column by name to the desired position after a column with a defined name.
You could use the data iris as an example.
Example:
data(iris)
Actual columns order:
> colnames(iris)
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
i would like to put "Petal.Width" after "Sepal.Length" by colnames using code and avoid putting manual inputs like selecting solutions with dplyr.
Thank you very much in advance.