title: Adjusting Kaplan curve in survival analysis
body: <pre><code>library(survival)
  library(ranger)
  library(ggplot2)
  library(dplyr)
  library(ggfortify)
  
  
  data(veteran)
  km_fit &lt;- survfit(Surv(time, status) ~ trt, data=veteran)
  autoplot(km_fit)
  
  
  km_fit &lt;- survfit(Surv(time, status) ~ trt + age, data=veteran)
  autoplot(km_fit)
  </code></pre>
  
  <p>How do you get adjusted KM curves? In this example when I add "age" to the survfit model I get this error:</p>
  
  <p><strong>Error in <code>levels&lt;-</code>(<code>*tmp*</code>, value = as.character(levels)) : 
    factor level [31] is duplicated</strong></p>
  
  <p>So how do you estimate adjusted KM curves and plot them?</p>