library(dplyr)
df <- data.frame(
USUBJID = as.character(seq(6)),
CNSR = c(0, 1, 1, 0, 0, 0),
AVAL = c(10.1, 20.4, 15.3, 20.8, 18.7, 23.4),
ARM = factor(c("A", "A", "A", "B", "B", "B"))
) %>%
mutate(is_event = CNSR == 0) %>%
mutate(n_events = as.integer(is_event))
basic_table() %>%
split_cols_by("ARM") %>%
add_colcounts() %>%
estimate_incidence_rate(
vars = "AVAL",
n_events = "n_events",
control = control_incidence_rate(
input_time_unit = "month",
num_pt_year = 100
)
) %>%
build_table(df)
Run the code above in your browser using DataLab