title: R apply advanced function on rownames
body: <p>at first, I would think that the following question is absolutely easy and I'm just not able to google or interpret it correctly, but if it is so, please show me a link, I will follow it.</p>
  
  <p>I put in a minimal example of my current problem, but I'm interested in this issue in general.</p>
  
  <pre><code>dataset &lt;- matrix(runif(10*3), nrow=10, ncol=3)
  rownames(dataset) &lt;- letters[1:dim(dataset)[1]]
  
  betas &lt;- matrix(0, nrow=dim(dataset)[1], ncol=2)
  rownames(betas) &lt;- letters[1:dim(dataset)[1]]
  colnames(betas) &lt;- c("sum", "2*sum")
  
  for(name in rownames(betas)){
      res1 &lt;- sum(dataset[name, ])
      res2 &lt;- res1 *2 
      betas[name, ] &lt;- c(res1, res2)
  }
  </code></pre>
  
  <p>This works fine of course, but I have ~20000 rows, so it's taking too much time.</p>
  
  <p>Can I use apply or one of its family to replace the loop?</p>
  
  <p><strong>Edit:</strong>
  I somewhere lost the last codesection where I commented why I have to do it this way.
  My real problem is the following, therefore I cant just make a sum and then multiply it later:</p>
  
  <pre><code>for(name in rownames(betas)){
      res1 &lt;- coxph("amazing survival model calculations")
      res2 &lt;- summary(res1) 
      betas[name, ] &lt;- c(res1$coef, res2$coef[5])
  }
  </code></pre>