I'm encountering a problem similar to Survival not recognizing right censored data but the suggested fix isn't working. I've confirmed that the censoring variable is numeric and I'm not encountering any problems when using coxph function. I only get the error when trying to visualize the p-value from Kaplan-Meier survfit function. Dataset is a standardized entry date, with weekly intervals to accompany a time-varying covariate used later in my cox models, dataset shown here https://drive.google.com/file/d/14nj8L-HatqqjbLZSzNLw1T-U9wFDlsCi/view?usp=sharing
library(readr)
library(survival)
library(survminer)
NOBO_surv_com <- read.csv("WSIdf.csv")
#Create censoring variable (right censoring)
NOBO_surv_com$censored[NOBO_surv_com$Death == 1] <- 1
NOBO_surv_com$censored[NOBO_surv_com$Death == 0 | NOBO_surv_com$Death == 2] <- 0
NOBO_surv_com$censored <- as.numeric(NOBO_surv_com$censored)
#Specify K-M Analysis model with categorical covariate (Year and Sex)
km_fit_Yr <- survfit(Surv(tstart, tstop, censored) ~ Yr,
data=NOBO_surv_com,
type="kaplan-meier")
print(km_fit_Yr)
surv_pvalue(km_fit_Yr, data = NOBO_surv_com)