Change order of column in data frame

I need to change the order of a certain data frame.
The difficulty is how to move one column after another.
I mean, move the column "dfg" before "kol".
I have no idea how to perform this simple task.
Can you help me?
Thanks for your time and interest

Hi, one way to do is, is to use the select() function from the dplyr package, one of the core packages from tidyverse. select() is a function to select variables from a data frame, but can be used to change the order of columns in a data frame as well.

See the examples in the reference of the select() function: or the chapter on in the excellent introduction R for Data Science

In the soon to be released version 1.0.0 of dplyra new function relocate() will make this even more comfortable (see

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.