R: Survfit function - getting p value for a specified time period I have been trying to find a way to get p-value for 6 months, 12 months and 5 years. 
library(survival)

fit <- survfit(Surv(futime, fustat) ~ rx,data=ovarian)
surv_pvalue(fit)$pval.txt

This produces: 
    [1] "p = 0.3"
I would like the p-value however, to only reference a certain time period.
fittime <- summary(fit,times=c(182.5))
surv_pvalue(fittime)$pval.txt

This also produces: [1] "p = 0.3"
The number remains the same no matter what time I try to use. I also tried it with different data where the curves are similar in the beginning yet completely different after a certain time, yet receive the same results. 
Any suggestions on how I would go about getting a 'p-value' for a certain time period ?
 A: Your problem is a common one and requires some insight into how the Kaplan-Meier statistic operates. Your code asks for the p-value of those with survival time less than 182.5 days. However, what you want is the p-value for all persons at-risk up to 182.5 days. This includes persons with survival time longer than 182.5 days. Your survival times and event status need to be recoded:
library(survival)
library(survminer)

for (i in 1:length(ovarian$fustat)) {
  if (ovarian$futime[i] >= 182.5) {
    ovarian$trunc6[i] <- 182.5
    ovarian$stat6[i] <- 0
  } else {
    ovarian$trunc6[i] <- ovarian$futime[i]
    ovarian$stat6[i] <- ovarian$fustat[i]
  }
}

Now, instead of curtailing the sample to only those patients with a survival time of less than 182.5 days, which is not the complete set of patients at risk (some lived longer), everyone at risk remains in the risk set. Then, reclassify those without an event at or beyond 182.5 days as free of the event while keeping those who suffered an event prior to 182.5 days as events with their usual survival time.
The call to surv_pvalue is then:
fit2 <- survfit(Surv(trunc6, stat6) ~ rx,data=ovarian)
surv_pvalue(fit2)

and results in a p-value of 0.071.
Note that the surv_pvalue function is contained in the package survminer not survival.
