I need your help! I have a data set with 100,000 cases and 81 variables and I run a loop for multiple regression for each variable adjusted for age and sex in r:
covariates <- c(var1, var2, ... var81)
purrr:: map(covariates, ~coxph(as.formula(paste("Surv(Time,Event) ~ Age + Sex +", .x)), data=mydata))
The output includes the coefficients for age, sex and for each variable, like that:
coef exp(coef) se(coef) z p
Age 0.0000 0.0000
Sex
Var1
I was wondering if there is a way for me to export in excel only the coefficient of each variable, aka only the third line, and not all the three of them.
Thank you so much for your help in advance!
Using
mtcars
as an example -Write the output to excel -