Learn R Programming

tidyBF (version 0.2.0)

bf_expr: Prepare caption with expression for Bayes Factor results

Description

Convenience function to create an expression with Bayes Factor results.

Usage

bf_expr(
  bf.df,
  k = 2L,
  output = "null",
  hypothesis.text = TRUE,
  caption = NULL,
  ...
)

Arguments

bf.df

A dataframe containing two columns log_e_bf01 (for evidence in favor of null hypothesis) and bf.prior. If dataframe contains more than two rows, only the first row will be used.

k

Number of digits after decimal point (should be an integer) (Default: k = 2).

output

Can either be "null" (or "caption" or "H0" or "h0"), which will return expression with evidence in favor of the null hypothesis, or "alternative" (or "title" or "H1" or "h1"), which will return expression with evidence in favor of the alternative hypothesis, or "results", which will return a dataframe with results all the details).

hypothesis.text

Logical that decides whether the expression containing result should have text to describe the hypothesis test being described. For output = "null", this is "In favor of null: ", otherwise "In favor of alternative: ".

caption

Text to display as caption (will be displayed on top of the Bayes Factor caption/message).

...

Additional arguments (ignored).

Examples

Run this code
# NOT RUN {
# for reproducibility
set.seed(123)
library(tidyBF)

# dataframe containing results
bf.df <-
  bf_extractor(BayesFactor::correlationBF(
    x = iris$Sepal.Length,
    y = iris$Petal.Length
  )) %>%
  dplyr::mutate(.data = ., bf.prior = 0.707)

# creating caption (for null)
bf_expr(
  bf.df,
  output = "null",
  k = 3,
  caption = "Note: Iris dataset"
)

# creating caption (for alternative)
bf_expr(bf.df, output = "alternative")
# }

Run the code above in your browser using DataLab