# glossary

## Setup

    library(glossary)

## Definition File

Set the default path to the definition file.

    glossary_path("glossary.yml")

### Definition YAML File

You can store definitions in a YAML file. Use markdown to create paragraphs, links, and lists. Make sure each new line in a definition is indented two spaces (sorry YAML is a bit picky, but it’s the best human-editable solution).

    SESOI: |
      Smallest Effect Size of Interest: the smallest effect that is theoretically or practically meaningful

      See [Equivalence Testing for Psychological Research](https://doi.org/10.1177/2515245918770963) for a tutorial on methods for choosing an SESOI.
    p-value: |
      The probability of the observed data, or more extreme data, if the null hypothesis is true. The lower the p-value, the higher the test statistic, and less likely it is to observe the data if the null hypothesis is true.

### Add Definitions with Code

Alternatively, you can add definitions to the file with code. You don’t need to indent new lines if you add definitions this way.

    glossary_add(term = "power",
                 def = "The probability of rejecting the null hypothesis when it is false, for a specific analysis, effect size, sample size, and criteria for significance."
    ")

### PsyTeachR Glossary

If you want to use the PsyTeachR Glossary, set the path to “psyteachr”. This will produce links to the online glossary when you click on the term, so it’s best to use with the “hover” popup type (see below).

    glossary_path("psyteachr")
    glossary_popup("hover")

absolute path

## Popup Type

Set the popup type with `glossary_popup()`; options are “click” (default), “hover”, and “none”.

    glossary_popup("none")

alpha

    glossary_popup("hover")

alpha

    glossary_popup("click")

alphaThe threshold chosen in Neyman-Pearson hypothesis testing to distinguish test results that lead to the decision to reject the null hypothesis, or not, based on the desired upper bound of the Type 1 error rate. An alpha level of 5% is most commonly used, but other alpha levels can be used as long as they are determined and preregistered by the researcher before the data is analyzed.

## Style

If your popup type is “click”, you must add a style with the `glossary_style()` function for the popups to work. If you set the popup type to “hover”, or “none”, you can omit this and the in-text glossary terms will be styled like other links in your document.

Set the style at the top of your document (set the code chunk to `results='asis'`). The code below shows the default options.

    glossary_style(color = "purple",
                   text_decoration = "underline",
                   def_bg = "#333",
                   def_color = "white")

Alternatively, you can add your own CSS to your document (inline or in an external linked file) to create a more customised appearance. Just copy the text returned by the `glossary_style()` function and customise it.

    # append default styles to an external CSS file
    write(glossary_style(), "glossary.css", append = TRUE)

## In-Text Terms

There are a few ways to customise the glossary term display.

- Look up a term from the glossary file with `glossary("alpha")`: alphaThe threshold chosen in Neyman-Pearson hypothesis testing to distinguish test results that lead to the decision to reject the null hypothesis, or not, based on the desired upper bound of the Type 1 error rate. An alpha level of 5% is most commonly used, but other alpha levels can be used as long as they are determined and preregistered by the researcher before the data is analyzed.

- Display a different value for the term with `glossary("alpha", "$\\alpha$")`: \(\alpha\)The threshold chosen in Neyman-Pearson hypothesis testing to distinguish test results that lead to the decision to reject the null hypothesis, or not, based on the desired upper bound of the Type 1 error rate. An alpha level of 5% is most commonly used, but other alpha levels can be used as long as they are determined and preregistered by the researcher before the data is analyzed.

- Use an inline definition instead of the glossary file with `glossary("beta", def = "The second letter of the Greek alphabet")`: betaThe second letter of the Greek alphabet

- Just show the term (no hover) with `glossary("effect size", show = "term")`: effect size'quantitative reflection of the magnitude of some phenomenon that is used for the purpose of addressing a question of interest' (Kelley & Preacher, 2012)

- Just show the definition with `glossary("p-value", show = "def")`: The probability of the observed data, or more extreme data, if the null hypothesis is true. The lower the p-value, the higher the test statistic, and less likely it is to observe the data if the null hypothesis is true.

## Glossary Table

Show the table of terms defined on this page (or since the last reset) with `glossary_table()`:

term | definition
--- | ---
absolute path | A file path that starts with / and is not appended to the working directory
alpha | The threshold chosen in Neyman-Pearson hypothesis testing to distinguish test results that lead to the decision to reject the null hypothesis, or not, based on the desired upper bound of the Type 1 error rate. An alpha level of 5% is most commonly used, but other alpha levels can be used as long as they are determined and preregistered by the researcher before the data is analyzed.
beta | The second letter of the Greek alphabet
effect size | ‘quantitative reflection of the magnitude of some phenomenon that is used for the purpose of addressing a question of interest’ (Kelley & Preacher, 2012)
p-value | The probability of the observed data, or more extreme data, if the null hypothesis is true. The lower the p-value, the higher the test statistic, and less likely it is to observe the data if the null hypothesis is true.

You can reset the glossary table between sections with `glossary_reset()`.