[R] insert new columns to a matrix

Daniel Folkinshteyn dfolkins at gmail.com
Tue Jun 24 16:37:40 CEST 2008

just cbind the cols in the appropriate order:

m.2 = cbind( m.1[,1:5], yourthreecolumns, m.1[,6:ncol(m.1)] )

on 06/24/2008 07:02 AM Daren Tan said the following:
> Instead of prepend or append new columns to a matrix, how to insert them to a matrix ? For example, I would like to insert 3 new columns after the 5th column of matrix m. 
> _________________________________________________________________
> [[elided Hotmail spam]]
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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