I'm getting the error Error in Surv(tte, eventfl) : object 'pfstte' not found, which is because it's not evaluating custom function's (hrdf) input parameters because they are column names of the indf dataframe. How do I pass a dataframe's column names into a custom function? I tried {{}}, [[]], eval(), and substitute, but none of these worked. Thanks!
hrdf <- function(indf, tte, eventfl) {
df <- broom::tidy(coxph(Surv(tte, eventfl) ~ ENRLARM_STD, data = indf[indf$SEX == 'Female',], ties = 'efron'), conf.int = T) %>%
dplyr::mutate(term = 'Sex', cat = 'Female')
return(df)
}
Try replacing the
Surv(tte, eventfl)portion by the following:I believe that should do the trick if you then pass the inputs
tteandeventflto your functionhrdf()as strings.