[R] request: To add an extra row in a matrix

Csardi Gabor csardi at rmki.kfki.hu
Mon Jun 2 11:12:08 CEST 2008


See ?rbind.

Gabor

On Mon, Jun 02, 2008 at 02:03:38AM -0700, Muhammad Azam wrote:
> Dear R users
> I have a problem regarding an addition of an extra "row" to a matrix. e.g. i have a matrix
> a <- matrix(1:6,2,3)
> > a
>      [,1] [,2] [,3]
> [1,]    1    3    5
> [2,]    2    4    6
> I want to add a matrix having just one row. e.g.
> b <- matrix(7:9,1,3)
> 
> > b
>      [,1] [,2] [,3]
> [1,]    7    8    9
> Now i want to get result like this
>      [,1] [,2] [,3]
> [1,]    1    3    5
> [2,]    2    4    6
> [3,]    7    8    9
> Can any body help to get the required result.  Thanks and
> 
> 
> best regards
> 
> Muhammad Azam 
> Ph.D. Student 
> Department of Medical Statistics, 
> Informatics and Health Economics 
> University of Innsbruck, Austria 
> 
> 
>       
> 	[[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.

-- 
Csardi Gabor <csardi at rmki.kfki.hu>    MTA RMKI, ELTE TTK



More information about the R-help mailing list