make_gmr_table is intended to save tables of geometric mean (GMs) and geometric mean rations (GMRs) into a report-ready table in various formats.

expr2char is a utility function to convert expression into character values which can be called prior to calling make_gmr_table (see examples)

make_gmr_table(
  data,
  file,
  format,
  headers,
  title,
  orientation = "landscape",
  abbreviations,
  n_label = "individual"
)

expr2char(x)

Arguments

data

a data.frame; typically a truncated version of a data.frame created using make_gmr_data in which only a select list of variables are kept

file

paths to one or more files to create

format

the format(s) of the output file, either 'html', 'word', or 'latex'. Length must match that of file

headers

a vector of character strings providing the column headers to be displayed in the output table

title

a title for the output table

orientation

control the page orientation for the output table, either 'landscape' or 'portrait'

abbreviations

a named list of abbreviations and abbreviation definition

n_label

a character value defining how individuals are defined in the abbreviation in the table footnote, that is, what is used in the definition of 'n' (eg, 'n, number of individuals'). By default, a 's' will be added to the entered value.

x

a vector of expressions

Value

this function is used for its side-effects and does not return any object

a character vector

Examples

if (FALSE) { # \dontrun{
# Use expo dataset provided in the ggcognigen package

gmrs <- make_gmr_data(
  x_var = c('CMAXSS', 'AUCSS', 'CMINSS'),
  data = expo,
  id_var = 'ID',
  by = 'DOSE',
  covariates = c('AGE', 'WTKG', 'BMI', 'SEXF', 'RFCAT', 'CPCAT'),
  labels = c(
    expression('Age'~'(y)'),
    expression('Body'~'Weight'~'(kg)'),
    expression('Body'~'Mass'~'Index'~'(kg/'*m^2*')'),
    expression('Sex'),
    expression('Renal'~'Function'),
    expression('Hepatic'~'Function')
  ),
  ref_levels = c(2, 3, 2, 1, 1, 1),
  digits = 3,
  silent = TRUE
)

gmrs2 <- gmrs[, c('x_var', 'y_label', 'value', 'by', 'n', 'gm_label','gmr_label')]
levels(gmrs2[, 'y_label']) <- expr2char(levels(gmrs2[, 'y_label']))

make_gmr_table(
  data = gmrs2,
  file = c(
    file.path(tempdir(), 'gmtable.html'),
    file.path(tempdir(), 'gmtable.docx')
 ),
  format = c('html', 'word'),
  headers = c(
    'Exposure Measure',
    'Covariate',
    'Group',
    'Dose',
    'n',
    'Geometric Mean [90% CI]',
    'Geometric Mean Ratio [90% CI]'
  ),
  abbreviations = list(
    CI = 'confidence interval'
  ),
  n_label = 'patient'
)
} # }