I have a dataset imported into R. I sucessfully ran survfit on the data set. I have one column with the periods survived by the patient and one column with (0/1) outcome whether the patient survived. I am know trying to do coxph()
on the data and am using the following.
coxph <- coxph(Surv(mydata$V11, mydata$event), method ="breslow")
However, I keep getting the following error. I have tried using as.numeric
on the variables but this still does not fix the problem. I have also tried removing mydata$
from each variable in the line of code above. Thank you.
Error: $ operator is invalid for atomic vectors
To prevent this error, you have to explicitly include
"formula ="
incoxph()
, as shown below.Also, if you're trying to model the null model, you need to include "
~ 1
" afterSurv()
.