Create a Function for Descriptive Statistics of a Dataset
Source:R/analyse_describe.R
analyse_describe.RdCreate a Function for Descriptive Statistics of a Dataset
Value
an analyse function that returns a list with the elements
followupfollow up timeeventstable of events vs. treatmenticeif column ice is present, table of intercurrent events, events, treatmentsubgroupif column subgroup is present, table of subgroup, events, treatment
A function that can be used in Summarise that returns a data frame with columns with means and standard deviations for every variable in the description.
Examples
condition <- merge(
assumptions_delayed_effect(),
design_fixed_followup(),
by=NULL
) |>
head(1)
dat <- generate_delayed_effect(condition)
analyse_describe()(condition, dat)
#> $n_pat
#> [1] 300
#>
#> $max_followup
#> [1] 8901
#>
#> $evt
#> [1] 300
#>
#> $evt_ctrl
#> [1] 150
#>
#> $evt_trt
#> [1] 150
#>
#> $study_time
#> [1] NA
#>
condition <- merge(
assumptions_delayed_effect(),
design_fixed_followup(),
by=NULL
) |>
tail(4) |>
head(1)
summarise_all <- create_summarise_function(
describe=summarise_describe()
)
# runs simulations
sim_results <- runSimulation(
design=condition,
replications=100,
generate=generate_delayed_effect,
analyse=list(
describe=analyse_describe()
),
summarise = summarise_all
)
# study time is missing, since there was no admin. censoring
sim_results[, 9:16]
#> # A tibble: 1 × 8
#> describe.n_pat describe.max_followup describe.evt describe.evt_ctrl
#> <dbl> <dbl> <dbl> <dbl>
#> 1 300 8866.8 300 150
#> # ℹ 4 more variables: describe.evt_trt <dbl>, describe.study_time <dbl>,
#> # describe.sd_n_pat <dbl>, describe.sd_max_followup <dbl>