On 17-04-2013, at 14:39, Christofer Bogaso <bogaso.christo...@gmail.com> wrote:

> Hello again,
> 
> Let say I have a matrix:
> 
> Mat <- matrix(1:12, 4, 3)
> 
> And a vector:
> 
> Vec <- 5:8
> 
> Now I want to do following:
> 
> Each element of row-i in 'Mat' will be divided by i-th element of Vec
> 
> Is there any direct way to doing that?


What have you tried?

Because of recycling and storage by columns of matrices and  and the fact 
length(Vec) == nrow(Mat)

Mat / Vec

will do.

Berend
______________________________________________
R-help@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.

Reply via email to