Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions analysis/km.R
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ if(length(exposure)>0){
max_fup_time = max(event_time),
max_event_time = max(event_time[event_indicator])
)
cat("maximum follow-up time is [", paste0(max_time_data$max_fup_time, collapse= ", "), "]", "\\n")
cat("maximum event time is [", paste0(max_time_data$max_event_time, collapse= ", "), "]", "\\n")
cat("maximum follow-up time is [", paste0(max_time_data$max_fup_time, collapse= ", "), "]", "\n")
cat("maximum event time is [", paste0(max_time_data$max_event_time, collapse= ", "), "]", "\n")
}


Expand Down Expand Up @@ -470,9 +470,18 @@ if(smooth){
km_plot <- function(.data) {

data_with_time0 <-
if(length(exposure)>0L){
.data |>
mutate(
"{exposure}" := as.factor(!!!exposure_syms)
)
} else {
.data
}

data_with_time0 <-
data_with_time0 |>
mutate(
"{exposure}" := as.factor(!!!exposure_syms),
lagtime = lag(time, 1, 0), # assumes the time-origin is zero
) %>%
group_modify(
Expand All @@ -486,6 +495,7 @@ km_plot <- function(.data) {
.before = 0
)
)

ggplot_init <- if(length(exposure)==0L){
ggplot(data_with_time0)
} else {
Expand Down