Showing 2 of 6 files from the diff.
Other files ignored by Codecov
DESCRIPTION has changed.
man/jskm.Rd has changed.
man/svyjskm.Rd has changed.
NEWS.md has changed.

@@ -25,6 +25,7 @@
Loading
25 25
#' @param table logical: Create a table graphic below the K-M plot, indicating at-risk numbers?
26 26
#' @param label.nrisk Numbers at risk label. Default = "Numbers at risk"
27 27
#' @param size.label.nrisk Font size of label.nrisk. Default = 10
28 +
#' @param cut.landmark cut-off for landmark analysis, Default = NULL
28 29
#' @param ... PARAM_DESCRIPTION
29 30
#' @return plot
30 31
#' @details DETAILS
@@ -69,6 +70,7 @@
Loading
69 70
                    table = F,
70 71
                    label.nrisk = "Numbers at risk",
71 72
                    size.label.nrisk = 10,
73 +
                    cut.landmark = NULL,
72 74
                    ...) {
73 75
  
74 76
  surv <- strata <- lower <- upper <- NULL
@@ -140,8 +142,10 @@
Loading
140 142
  if (cumhaz){
141 143
    df$surv <- 1 - df$surv
142 144
    if (ci){
143 -
      df$lower <- 1 - df$upper
144 -
      df$upper <- 1 - df$lower
145 +
      upper.new <- 1 - df$lower
146 +
      lower.new <- 1 - df$upper
147 +
      df$lower = lower.new
148 +
      df$upper = upper.new
145 149
    }
146 150
    }
147 151
  

@@ -29,7 +29,8 @@
Loading
29 29
#' @param cumhaz Show cumulaive hazard function, Default: F
30 30
#' @param cluster.option Cluster option for p value, Option: "None", "cluster", "frailty", Default: "None"
31 31
#' @param cluster.var Cluster variable
32 -
#' @param data select specific data - for reactive input. Default = NULL
32 +
#' @param data select specific data - for reactive input, Default = NULL
33 +
#' @param cut.landmark cut-off for landmark analysis, Default = NULL
33 34
#' @param ... PARAM_DESCRIPTION
34 35
#' @return Plot
35 36
#' @details DETAILS
@@ -104,6 +105,7 @@
Loading
104 105
                 cluster.option = "None",
105 106
                 cluster.var = NULL,
106 107
                 data = NULL,
108 +
                 cut.landmark = NULL,
107 109
                 ...) {
108 110
  
109 111
  
@@ -183,11 +185,44 @@
Loading
183 185
    upper = sfit$upper[subs2],
184 186
    lower = sfit$lower[subs2]
185 187
  )
188 +
189 +
  if (!is.null(cut.landmark)){
190 +
    if (is.null(data)){
191 +
      stop("Landmark analysis requires data object. please check 'data' option")
192 +
    }
193 +
    
194 +
    var.time <- as.character(sfit$call$formula[[2]][[2]])
195 +
    var.event <- as.character(sfit$call$formula[[2]][[3]])
196 +
    data1 <- data
197 +
    data1[[var.event]][data1[[var.time]] >= cut.landmark] <- 0
198 +
    data1[[var.time]][data1[[var.time]] >= cut.landmark] <- cut.landmark
199 +
  
200 +
    sfit1 <- survfit(as.formula(sfit$call$formula), data1)
201 +
    sfit2 <- survfit(as.formula(sfit$call$formula), data[data[[var.time]] >= cut.landmark, ])
202 +
    
203 +
    if (levels(Factor) == "All"){
204 +
      df2 <- merge(subset(df, time >= cut.landmark)[, c("time", "n.risk", "n.event", "n.censor", "strata")], 
205 +
                   data.frame(time = sfit2$time, surv = sfit2$surv, strata = "All", upper = sfit2$upper, lower = sfit2$lower), 
206 +
                   by = c("time", "strata"))
207 +
    } else{
208 +
      df2 <- merge(subset(df, time >= cut.landmark)[, c("time", "n.risk", "n.event", "n.censor", "strata")], 
209 +
                   data.frame(time = sfit2$time, surv = sfit2$surv, strata = rep(names(sfit2$strata), sfit2$strata), upper = sfit2$upper, lower = sfit2$lower), 
210 +
                   by = c("time", "strata"))
211 +
    }
212 +
    
213 +
    
214 +
    
215 +
    df11 <- rbind(subset(df, time < cut.landmark), df2) 
216 +
    df <- rbind(df11, data.frame(time = cut.landmark, n.risk = summary(sfit, times = cut.landmark)$n.risk,  n.event = 0, n.censor = 0, surv = 1, strata = factor(ystratalabs, levels = levels(df$strata)), upper = 1, lower = 1))
217 +
  }
218 +
  
186 219
  
187 220
  if (cumhaz){
188 -
    df$surv = 1 - sfit$surv[subs2]
189 -
    df$lower = 1 - sfit$upper[subs2]
190 -
    df$upper = 1 - sfit$lower[subs2]
221 +
    upper.new <- 1 - df$lower
222 +
    lower.new <- 1 - df$upper
223 +
    df$surv = 1 - df$surv
224 +
    df$lower = lower.new
225 +
    df$upper = upper.new
191 226
    
192 227
  }
193 228
  
@@ -270,6 +305,10 @@
Loading
270 305
    } 
271 306
  }
272 307
  
308 +
  if (!is.null(cut.landmark)){
309 +
    p <- p + geom_vline(xintercept = cut.landmark, lty = 2)
310 +
  }
311 +
  
273 312
  ## Create a blank plot for place-holding
274 313
  blank.pic <- ggplot(df, aes(time, surv)) +
275 314
    geom_blank() + theme_void() +             ## Remove gray color
@@ -282,7 +321,8 @@
Loading
282 321
  # p-value placement #
283 322
  #####################a
284 323
  
285 -
  if(length(levels(summary(sfit)$strata)) == 0) pval <- FALSE
324 +
  if(length(levels(summary(sfit)$strata)) == 0) pval <- F
325 +
  if(!is.null(cut.landmark)) pval <- F
286 326
  
287 327
  if(pval == TRUE) {
288 328
    if (is.null(data)){
Files Coverage
R 77.61%
Project Totals (2 files) 77.61%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading