Re: [R] Swap variables in data.frame

From: Karl Ove Hufthammer <>
Date: Mon, 02 Jun 2008 11:48:06 +0200

Birgit Lemcke:

> I have a dataframe and two of my variables are in the wrong position
> and I would like to swap those variables.

To swap column 1 and 2, try


Note that this is different from


which will swap the data, but not the column names.

Karl Ove Hufthammer

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 02 Jun 2008 - 09:57:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 02 Jun 2008 - 11:30:35 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive