Thanks, but isn't that only for elements in vectors? I think I've found the following method to work:
e.g. for df <- data.frame(v1,v2,v3,v4) use: df <- data.frame(df[1:2],v5,df[-c(1:2)]) I *believe* this is the one-line solution I was looking for. Can anyone see why this wouldn't work? Jon -----Original Message----- From: Christos Hatzis [mailto:[EMAIL PROTECTED] Sent: 13 September 2006 23:22 To: 'Jon Minton'; r-help@stat.math.ethz.ch Subject: RE: [R] inserting columns in the middle of a dataframe See ?append -Christos -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon Minton Sent: Wednesday, September 13, 2006 5:14 PM To: r-help@stat.math.ethz.ch Cc: 'Jon Minton' Subject: Re: [R] inserting columns in the middle of a dataframe Dear R users: Is there a built-in and simple way to insert new columns after other columns in a dataframe? I.e. currently I have: V1 V2 V3 V4 [1,] [2,] Etc. But I want V1 V5 V2 V3 V4 [1,] [2,] Etc. Can this be done in one line? Jon Minton [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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.