[R] How to add a new column to a matrix?

David Winsemius dwinsemius at comcast.net
Sun Oct 10 06:12:09 CEST 2010


On Oct 9, 2010, at 11:16 PM, Lakshmi Kastury wrote:

>
> Hi -
> I am a beginner to the R language. I have written the following  
> matrix: Z.mat=matrix(c(2,2,2,1,1,1,3,2,1,6,5,4,9,1,1,2,3,2), nrow=6)
> I would like to add a 4th column consisting of: 6, 9, 8, 15, 16, 17

?cbind
>
> I would also like to name each column a, b, c, d as well.

The help page for matrix seems to be perfectly clear on this point.

?matrix

-- 
David
>
> Thanks!
> 		 	   		
> 	[[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