title: R - Extract summary table from Survfit with Strata
body: <p>I'm new to R and survival analysis, and I am interested to export into a dataframe the results from survfit where there is strata. </p>
  
  <p>This site has provided an excellent solution but not to one with strata (<a href="https://stat.ethz.ch/pipermail/r-help/2014-October/422348.html" rel="noreferrer">https://stat.ethz.ch/pipermail/r-help/2014-October/422348.html</a>). How can i append (or stack) each strata with an extra column which contains the strata type.
  solution in the link offered is not applicable to strata groupings</p>
  
  <pre><code>library(survival)
  data(lung)
  mod &lt;- with(lung, survfit(Surv(time, status)~ 1))
  res &lt;- summary(mod)
  str(res)
  
  # Extract the columns you want
  cols &lt;- lapply(c(2:6, 8:10) , function(x) res[x])
  # Combine the columns into a data frame
  tbl &lt;- do.call(data.frame, cols)
  str(tbl)
  </code></pre>
  
  <p>Thank you in advanced,
  R newbie</p>