metabulate: Write a summary table of meta-analytic results

View source: R/output.R

metabulateR Documentation

Write a summary table of meta-analytic results

Description

Write a summary table of meta-analytic results

Usage

metabulate(
  ma_obj,
  file = NULL,
  output_dir = getwd(),
  output_format = c("word", "html", "pdf", "odt", "text", "rmd"),
  show_msd = TRUE,
  show_conf = TRUE,
  show_cred = TRUE,
  show_se = FALSE,
  show_var = FALSE,
  analyses = "all",
  match = c("all", "any"),
  case_sensitive = TRUE,
  ma_method = "ad",
  correction_type = "ts",
  collapse_construct_labels = TRUE,
  bold_headers = TRUE,
  digits = 2L,
  decimal.mark = getOption("OutDec"),
  leading0 = "conditional",
  drop0integer = FALSE,
  neg.sign = "−",
  pos.sign = "figure_html",
  big.mark = " ",
  big.interval = 3L,
  small.mark = " ",
  small.interval = 3L,
  na.mark = "—",
  lgl.mark = c("+", "−"),
  inf.mark = c("+∞", "−∞"),
  conf_format = "brackets",
  cred_format = "brackets",
  symbol_es = "ES",
  caption = "Results of meta-analyses",
  header = NULL,
  verbose = FALSE,
  unicode = NULL,
  bib = NULL,
  title.bib = NULL,
  style = "apa",
  additional_citekeys = NULL,
  save_build_files = FALSE,
  ...
)

Arguments

ma_obj

A psychmeta meta-analysis object.

file

The filename (optionally with a subfolder path) for the output file. If NULL, the function will output directly to the R console (also useful if you want to include psychmeta results in a larger RMarkdown document).

output_dir

The filepath for the output directory/folder. Defaults to the current working directory.

output_format

The format of the output tables. Available options are Word (default), HTML, PDF (requires LaTeX and the unicode-math LaTeX package to be installed), ODT, rmd (Rmarkdown), and text (plain text). You can also specify the full name of another RMarkdown output_format.

show_msd

Logical. Should means and standard deviations of effect sizes be shown (default TRUE)

show_conf

Logical. Should confidence intervals be shown (default: TRUE)?

show_cred

Logical. Should credibility intervals be shown (default: TRUE)?

show_se

Logical Should standard errors be shown (default: FALSE)?

show_var

Logical. Should variances be shown (default: FALSE)?

analyses

Which analyses to extract references for? See filter_ma for details.

match

Match all or any of the filter criteria? See filter_ma for details.

case_sensitive

Logical scalar that determines whether character values supplied in analyses should be treated as case sensitive (TRUE, default) or not (FALSE).

ma_method

Meta-analytic methods to be included. Valid options are: "ad", "ic", and "bb". Multiple methods are permitted. By default, results are given for one method with order of priority: 1. "ad", 2. "ic", 3. "bb".

correction_type

Type of meta-analytic corrections to be incldued. Valid options are: "ts" (default), "vgx", and "vgy". Multiple options are permitted.

collapse_construct_labels

Should the construct labels for construct pairs with multiple rows of results be simplified so that only the first occurence of each set of construct names is shown (TRUE; default) or should construct labels be shown for each row of the table (FALSE).

bold_headers

Logical. Should column headers be bolded (default: TRUE)?

digits, decimal.mark, leading0, drop0integer, neg.sign, pos.sign, big.mark, big.interval, small.mark, small.interval, na.mark, lgl.mark, inf.mark

Number formatting arguments. See format_num for details.

conf_format

How should confidence intervals be formatted? Options are:

  • parentheses: Bounds are enclosed in parentheses and separated by a comma: (LO, UP).

  • brackets: Bounds are enclosed in square brackets and separated by a comma: [LO, UP].

  • columns: Bounds are shown in individual columns.

cred_format

How should credility intervals be formatted? Options are the same as for conf_format above.

symbol_es

For meta-analyses of generic (non-r, non-d) effect sizes, the symbol used for the effect sizes (default: symbol_es = "ES").

caption

Caption to print before tables. Either a character scalar or a named character vector with names corresponding to combinations of ma_method and correction_type (i.e., bb, ic_ts, ad_vgx, etc.).

header

A list of YAML header parameters to pass to render.

verbose

Logical. Should detailed SD and variance components be shown (default: FALSE)?

unicode

Logical. If output_format is "text", should UTF-8 characters be used (defaults to system default).

bib

A BibTeX file containing the citekeys for the meta-analyses. If provided and file is not NULL, a bibliography will be included with the meta-analysis table. See generate_bib for additional arguments controlling the bibliography.

title.bib

The title to give to the bibliography (see bib above). If NULL, defaults to "Sources Contributing to Meta-Analyses"

style

What style should the bibliography (see bib above) be formatted in? Can be a file path or URL for a CSL citation style or the style ID for any style available from the Zotero Style Repository). Defaults to APA style. (Retrieving a style by ID requires an internet connection. If unavailable, references will be rendered in Chicago style.).

additional_citekeys

Additional citekeys to include in the reference list (see bib above).

save_build_files

Should the RMarkdown and BibLaTeX (if any) files used to generate the output be saved (default: FALSE)?

...

Additional arguments to pass to render.

Value

A list of meta-analysis results tibbles with "caption" and "footnote" attributes.

If file is specified, formatted tables and bibliographies are exported in the requested output_format.

Formatted tables of meta-analytic output.

See Also

Other output functions: generate_bib(), metabulate_rmd_helper()

Examples

## Not run: 
## Create a results table for meta-analysis of correlations and output to Word:
ma_r_obj <- ma_r(ma_method = "ic", rxyi = rxyi, n = n, rxx = rxxi, ryy = ryyi,
                 construct_x = x_name, construct_y = y_name,
                 moderators = moderator, data = data_r_meas_multi)
metabulate(ma_obj = ma_r_obj, file = "meta tables correlations",
           output_format = "word", output_dir = tempdir())

## Output to PDF:
metabulate(ma_obj = ma_r_obj, file = "meta tables correlations",
           output_format = "pdf", output_dir = tempdir())

## Output to ODT (LibreOffice):
metabulate(ma_obj = ma_r_obj, file = "meta tables correlations",
           output_format = "odt", output_dir = tempdir())


## To produce Markdown tables to include inline in an RMarkdown report,
## leave file == NULL and output_format to anything but "text":
ma_table <- metabulate(ma_obj = ma_r_obj, file = NULL, output_format = "rmd")

## Use the metabulate_rmd_helper() function to ensure all symbols render properly.
Insert the following code as 'as-is' output:
metabulate_rmd_helper()

## Then, add the formatted table to your document using your preferred table
## formatting functions:

#### Using just the 'knitr' package, include the following as 'as-is' output:
knitr::kable(ma_table[[1]], caption = attr(ma_table[[1]], "caption"))
cat("\n", attr(ma_table[[1]], "footnote"))

#### Using 'knitr' plus the 'kableExtra' package:
knitr::kable(ma_table[[1]], "latex", booktabs = TRUE,
                  caption = attr(ma_table[[1]], "caption")) %>%
       kableExtra::kable_styling(latex_options = c("striped", "hold_position")) %>%
       kableExtra::footnote(general = attr(ma_table[[1]], "footnote")

# !!! Note: On Windows, R currently can only handle Unicode characters if kables
# are printed at top-level (e.g., not in an if() statement, in a for() loop,
# or in lapply() or map() ). To correctly print Unicode metabulate tables, call
# kable() as a top-level function (as above).


## Create output table for meta-analysis of d values:
ma_d_obj <- ma_d(ma_method = "ic", d = d, n1 = n1, n2 = n2, ryy = ryyi,
                 construct_y = construct, data = data_d_meas_multi)
ma_d_obj <- ma_d_ad(ma_obj = ma_d_obj, correct_rr_g = FALSE, correct_rr_y = FALSE)
metabulate(ma_obj = ma_d_obj, file = "meta tables d values", output_dir = tempdir())

## Create output table for meta-analysis of generic effect sizes:
dat <- data.frame(es = data_r_meas_multi$rxyi,
                  n = data_r_meas_multi$n,
                  var_e = (1 - data_r_meas_multi$rxyi^2)^2 / (data_r_meas_multi$n - 1))
ma_obj <- ma_generic(es = es, n = n, var_e = var_e, data = dat)
metabulate(ma_obj = ma_obj, file = "meta tables generic es", output_dir = tempdir())

## End(Not run)

psychmeta/psychmeta documentation built on Feb. 12, 2024, 1:21 a.m.