Skip to contents

Functions to setup studies

cctu_initialise() cctu_initialize() cctu_check_dir() rm_output()
initialise objects for using cctu package
attach_pop() detach_pop()
Functions that attach and detach environments based on which populations are used for a given table number
clean_up()
removes all the objects in the environment, apart from those listed in reserved and detaches the environment used to create tables or figures corresponding to the number
data_table_summary()
Provides a summary with date stamps of external data files.
order_dewey()
sorts inputs that look like Dewey decimal numbering
get_meta_table() set_meta_table()
Functions to handle meta_table
get_code_tree() reset_code_tree()
track which files of code are called by which oher files
print(<code_tree>)
Print methods for code_tree object
plot(<code_tree>)
Print/plot the code tree.
create_popn_envir()
create environments contain a set of data frames filtered for each population
rm_envir()
A function to remove all attached objects from the search path with any exceptions specified
run_batch()
Runs a script in batch mode directly from within R.
source()
A modified version of the source() function to capture in a data.frame what file was called and from which file
read_data()
Automatic reading in data from a meta-table of external data sets.
meta_table_example
Example of a meta_table data frame

Macro utility functions

Functions manipulating MACRO data

apply_macro_dict()
Apply DLU/CLU file to the data frame
extract_form()
Extract data by form from MACRO dataset
merge_data()
Merge vertically split data
set_dlu() get_dlu()
Set/get DLU data
tidy_dlu()
Tidy DLU form
dump_missing_report() get_missing_report() reset_missing_report()
Save/Get/Reset missingness report

Formating/conversion function

Functions to format digits, convert characters.

format_percent()
Format number to percent
format_pval()
Format p-value
signif_pad() round_pad()
Round numbers with 0-padding.
p_format()
formats p values with rounding and <0.001
to_factor() to_character() to_numeric() to_logical()
Convert vector but keep value/value labels.
propercase()
Function to convert text to proper case

Summry data

Functions to create summary statistics

cttab()
Generate an table of descriptive statistics.
print(<cttab>)
Print
rbind(<cttab>)
Combine descriptive statistics table by rows
render_cat()
Render categorical values for table output.
render_numeric()
Render continuous values for table output.
num_stat() cat_stat()
Compute some basic descriptive statistics.
sumby()
Produces summary statistics on a variable broken down by arm, display a graphical equivalent.
sumfig()
Produce ggplot to represent summary statistics graphically, either boxplot or barchart
regression_table()
Produce a table summarising a regression model for a study report

Plotting

Functions to create plots

geom_stepribbon()
Step ribbon plots.
km_ggplot()
Create a Kaplan-Meier plot using ggplot2
plot(<km_ggplot>)
plot methods for km_ggplot object
print(<km_ggplot>)
print methods for km_ggplot object

Writing outputs

Functions to write tables, figures and report

write_docx()
Produces the final Docx file
write_ggplot()
Function to save ggplot figures.
write_manual()
Function to write to meta-table and clean up without creating a table,text, or figure. For manual use
write_plot()
Function to save plot figures
write_table()
Function to write a table into xml format in the correct directory, and edit TableofTables
write_text()
Function to write a text into xml format in the correct directory, and edit TableofTables
create_word_xml()
Produces the final xml file

Variable and value labels

Functions for labels

val_lab() `val_lab<-`() has.labels() unval()
Set or get value labels
var_lab() `var_lab<-`() has.label() drop_lab()
Set or get variable label
unlab()
Drop variable label and value labels
copy_lab()
Copy variable label and value labels
lab2val()
Replace vector/matrix/data.frame values with corresponding value labels.

Miscellaneous

all_is_numeric()
Check if All Elements in Character Vector are Numeric
clean_names() clean_string()
Tidies up names of a data frame within certain rules
detect_invalid_utf8() remove_invalid_utf8()
Functions to detect and delete non-UTF8 characters, which the XML output will not like
is_empty()
Check whether string, list or vector is empty
rbind_space()
Function to bind tables/matrices with a blank row between them
remove_blank_rows_cols()
Function to remove blank rows/columns from a df