matrix(1:12,nrow=3) # [,1] [,2] [,3] [,4] # [1,] 1 4 7 10 # [2,] 2 5 8 11 # [3,] 3 6 9 12
t(t(matrix(1:12,nrow=3))/c(2,3,4,5)) # [,1] [,2] [,3] [,4] # [1,] 0.5 1.333333 1.75 2.0 # [2,] 1.0 1.666667 2.00 2.2 # [3,] 1.5 2.000000 2.25 2.4 Ted. On 11-Mar-10 12:47:53, Dimitris Rizopoulos wrote: > say 'mat' is your matrix and 'vec' is your vector, then try this: > > mat / rep(vec, each = m) > > > I hope it helps. > > Best, > Dimitris > > > On 3/11/2010 1:44 PM, [email protected] wrote: >> Hi, >> I have a matrix with m rows and n column and a vector with n >> elements. I >> want to divid each rows of the matrix by vector direcly. >> could you please hint me? >> >> Thank you >> khazaei >> >> ______________________________________________ >> [email protected] 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. >> > > -- > Dimitris Rizopoulos > Assistant Professor > Department of Biostatistics > Erasmus University Medical Center > > Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands > Tel: +31/(0)10/7043478 > Fax: +31/(0)10/7043014 > > ______________________________________________ > [email protected] 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. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[email protected]> Fax-to-email: +44 (0)870 094 0861 Date: 11-Mar-10 Time: 15:22:01 ------------------------------ XFMail ------------------------------ ______________________________________________ [email protected] 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.

