Hi,
What is the elegant script to divide the columns of a matrix by the respective
position of a vector elements?
m=rbind(c(6,4,2),c(3,2,1))
v= c(3,2,1)
res= 6/3 4/2 2/1
3/3 2/2 1/1
this is correct
mat2 = NULL
for (i in 1: ncol(m))
mat2 = cbind(mat2, m[,i]/ v[i])
but how to do more compact and elegant with for ex do.call?
Many thanks
Carol
[[alternative HTML version deleted]]
______________________________________________
[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.