[R] Inserting column in between

Sarah Goslee sarah.goslee at gmail.com
Mon Aug 1 19:10:05 CEST 2011


x <- cbind(x[,1:29], newcolumn, x[,30:ncol(x)])

On Mon, Aug 1, 2011 at 12:59 PM, Bansal, Vikas <vikas.bansal at kcl.ac.uk> wrote:
> Dear all,
>
> I have a very simple question.I have data frame of 50 columns and i want to insert a column in 30th position.But i do not want to delete that column.Is it possible to include a column in between, so that new values are in 30th column and 30 th column is now 31st and 31st is 32nd......so on and 50th column is 51st..?I will be very thankful to you.
>
>



-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list