Create a Function for Descriptive Statistics of a Dataset
Source:R/analyse_describe.R
analyse_describe.Rd
Create a Function for Descriptive Statistics of a Dataset
Value
an analyse function that returns a list with the elements
followup
follow up timeevents
table of events vs. treatmentice
if column ice is present, table of intercurrent events, events, treatmentsubgroup
if 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
)
#>
#>
Design: 1/1; RAM Used: 158.6 Mb; Replications: 100; Total Time: 0.00s
#> Conditions: delay=121., hzrd_c=0.0009, hzrd_t=0.0006, rndm_w=0.0001, n_trt=150, n_ctrl=150, follwp=730., rcrtmn=182.
#>
#>
#> Simulation complete. Total execution time: 0.11s
# 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 9020.8 300 150
#> # ℹ 4 more variables: describe.evt_trt <dbl>, describe.study_time <dbl>,
#> # describe.sd_n_pat <dbl>, describe.sd_max_followup <dbl>