I think it should be possible to create the column at the end and then use "order" on the columns names and indexes to only change the order of column indexes, rather than having to do operations on the data itself (which will be very time consuming if the dataset is large). Perhaps people with better R skills can suggest how to code this. Anupam.
______________________________________________ R-help@stat.math.ethz.ch 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.