title: Extracting pvalues and se(coef) from coxph in R
body: <p>I am trying to streamline my code to avoid for loops but am having a hard time once I run my cox proportional hazards code to extract p-values and standard errors for the coefficients. My code is as follows:</p>
  
  <pre><code>library(survival)
  
  #Generate Data
  x = matrix(rbinom(10000,1,.5),ncol=100)
  y = rexp(ncol(x),.02)
  censor = rbinom(ncol(x),1,.5)
  event = ifelse(censor==1,0,1)
  
  #Fit the coxph model to the data
  ans = apply(x,1,function(x,y,event)coxph(Surv(y,event)~x),y=y,event=event)
  
  #Extract the coefficients from ans
  coef = unname(sapply(ans,function(x)x$coef))
  </code></pre>
  
  <p>So as you can see, I am able to extract the coefficients from the object <code>ans</code>, but I cannot extract the p-values and standard errors. Is there an easy way to do this from my <code>ans</code> object? Or a simple way to modify this code to do it?</p>