cohort_fn {reappraised} | R Documentation |
Creates flextable of probability of matching mean, SD, and mean and SD for each variable in different cohorts in the
specified number of simulations
cohort_fn(
df = cohort_data,
seed = 0,
sims = -1,
n_vars = 10,
popn = "",
title = "",
verbose = TRUE
)
df |
data frame generated from load_clean function |
seed |
the seed to use for random number generation, default 0 = current date and time. Specify seed to make repeatable. |
sims |
number of simulations, default -1 = function selects based on number of variables and sample size. |
n_vars |
restrict analyses to variables in at least (>=) this number of cohorts, default = 10 (ie variable has mean in 10 or more cohorts). |
popn |
if dataset contains studies in different sub-populations, code this in cohort_data$population and studies are subsetted if match in this variable. 'All' overrides this and uses all data regardless of information in this variable. |
title |
title name for plots (optional) |
verbose |
TRUE or FALSE indicates whether progress bar and comments show and flextable is printed |
Reference data is from Bolland 2021
Bolland MJ, Gamble GD, Avenell A, Grey A. Identical summary statistics were uncommon in randomized trials and cohort studies. J Clin Epidemiol 2021;136:180-188.
Returns a list containing 6 objects and (if verbose = TRUE) prints the flextable cohort_ft
list containing 6 objects as described
cohort_ft = flextable of results
cohort_graph = plot of observed to expected numbers of matches per cohort for mean; SD; and mean and SD
all_graphs = list containing
all_graphs = all plots on single plot
both_graphs = list of 3 plots row by row used to form all_graphs
individual_graphs= list of 6 individual plots used to form all_graphs
cohort_cohort_data = data frame used to generate results data
cohort_prob_data = data frame used to make flextable
cohort_oe_data= data frame used to make observed to expected plots
# load example data
cohort_data <- load_clean(import= "no", file.cont = "SI_cohort", cohort= "yes",
format.cont = "long")$cohort_data
# run function (takes close to 5 seconds)
cohort_fn(seed=10, sims = 100)$cohort_ft
# to import an excel spreadsheet (modify using local path,
# file and sheet name, range, and format):
# get path for example files
path <- system.file("extdata", "reappraised_examples.xlsx", package = "reappraised",
mustWork = TRUE)
# delete file name from path
path <- sub("/[^/]+$", "", path)
# load data
cohort_data <- load_clean(import= "yes", cohort = "yes", dir = path,
file.name.cont = "reappraised_examples.xlsx", sheet.name.cont = "SI_cohort",
range.name.cont = "A1:F101", format.cont = "long")$cohort_data