[R] Odp: Outputting csv file from dataframe with columns in a particular order

Petr PIKAL petr.pikal at precheza.cz
Wed Jan 12 16:36:25 CET 2011


Hi

r-help-bounces at r-project.org napsal dne 12.01.2011 16:16:16:

> I have a dataframe with columns "ID",'date","estimate","actual" (but
> not necessarily in that order - I do a merge somewhere and that
> somehow messes up the order of the columns).

If you have datafreme with column order a, b, c, d and you want b, c, d, a 
just order columns accordingly

write.table(df[,c("b", "c", "d", "s")], ....)

Regards
Petr


> 
> How can I output it to a csv file with the columns in the order that I
> want?
> 
> Thanks.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list