Skip to contents

Convenience constructor: wraps Condition$new() with an enroll_trigger(). The returned Condition should be passed to Trial$new(conditions = list(...)).

Usage

condition_enrollment_fraction(
  fraction,
  sample_size,
  analysis = NULL,
  name = NULL
)

Arguments

fraction

numeric Sample fraction (0 < fraction <= 1).

sample_size

integer Target sample size.

analysis

function or NULL Called as analysis(df, current_time, ...). If NULL, the filtered snapshot is returned as-is with a warning.

name

character or NULL Result key. Defaults to "frac_<fraction>".

Value

A Condition object.

Examples

cond <- condition_enrollment_fraction(
  fraction    = 0.5,
  sample_size = 100,
  analysis    = function(df, current_time) {
    data.frame(n_enrolled = sum(!is.na(df$enroll_time)))
  }
)