R/draw_sw.R
draw_sw.Rd
draw_sw
draws stepped-wedge cluster randomised trial (SW-CRT)
design diagrams that can be exported in .docx, .png, and .pptx formats.
draw_sw(design = design_sw(), cp_contents = design, row_names = FALSE, col_names = FALSE, colours, combine_rows = FALSE, merge_cols = FALSE, xlab = "Time period", ylab = "Cluster", cp_text_colour = "black", key_interventions, key_time_periods, make = "print", filename = "swcrt")
design | A SW-CRT design (i.e., information on the planned roll-out) to
draw a diagram for. Must be either a |
---|---|
cp_contents | Values to add to the cluster-period cells in the produced
diagram; modify this when cluster-period cells should contain details
on something other than the intervention condition. Must be either a
|
row_names | A |
col_names | A |
colours | A named (see |
combine_rows | A |
merge_cols | A |
xlab | A |
ylab | A |
cp_text_colour | A |
key_interventions | A named (see |
key_time_periods | A named (see |
make | A |
filename | A |
A list
containing the following elements:
A flextable
in the slot $table_design
containing
the constructed SW-CRT diagram.
A flextable
in the slot $table_interventions
containing the constructed key summarising the various intervention states.
Will be NULL
if input key_interventions
is not
specified.
A flextable
in the slot $table_time_periods
containing the constructed key summarising the various time periods.
Will be NULL
if input key_time_periods
is not
specified.
A list
in the slot $inputs
containing each of the
input variables.
More details on each of the input variables can be found in the package
vignette
.
Michael J Grayling (michael.grayling@newcastle.ac.uk)
# The default is to draw a 'standard' SW-CRT design, with four clusters and # five time periods default_draw <- draw_sw()#> a flextable object. #> col_keys: `Cluster`, `i`, `1`, `2`, `3`, `4`, `5` #> header has 1 row(s) #> body has 4 row(s) #> original dataset sample: #> Cluster i 1 2 3 4 5 #> 1 Cluster 1 0 1 1 1 1 #> 2 Cluster 2 0 0 1 1 1 #> 3 Cluster 3 0 0 0 1 1 #> 4 Cluster 4 0 0 0 0 1# Specify a more complex design, where all clusters begin in the intervention # condition, there is an unequal number of clusters who switch per time # period, and there are two trailing extra time periods with all clusters in # the intervention condition. Also modify the row and column names complex_design <- design_sw(clusters_per_time_period = c(1, 2, 3, 2, 0, 0), row_names = paste("Cluster", 1:8), col_names = paste("Time period", 1:6)) # Pass this to draw_sw(), producing .docx, .png, and .pptx files, merging # columns, and combining rows if (FALSE) { complex_draw <- draw_sw(complex_design, combine_rows = TRUE, merge_cols = TRUE, make = c("docx", "png", "pptx", "print")) }