Skip to content

Commit 5259c4c

Browse files
committed
ensure if exposure not set then plotting works
1 parent 552d12a commit 5259c4c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

analysis/km.R

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,18 @@ if(smooth){
470470
km_plot <- function(.data) {
471471

472472
data_with_time0 <-
473+
if(length(exposure)>0L){
473474
.data |>
475+
mutate(
476+
"{exposure}" := as.factor(!!!exposure_syms)
477+
)
478+
} else {
479+
.data
480+
}
481+
482+
data_with_time0 <-
483+
data_with_time0 |>
474484
mutate(
475-
"{exposure}" := as.factor(!!!exposure_syms),
476485
lagtime = lag(time, 1, 0), # assumes the time-origin is zero
477486
) %>%
478487
group_modify(
@@ -486,6 +495,7 @@ km_plot <- function(.data) {
486495
.before = 0
487496
)
488497
)
498+
489499
ggplot_init <- if(length(exposure)==0L){
490500
ggplot(data_with_time0)
491501
} else {

0 commit comments

Comments
 (0)