Inline Reporting Redux

Inline reporting of values is one of the strengths of R, RMarkdown, and Quarto. Here we look at the use of the epoxy library for improved inline reporting.

how-to
R Markdown
quarto
inline
Author

Nathan Craig

Published

March 12, 2024

Modified

March 21, 2024

In a couple of other posts, I discussed strategies for inline reporting of \(p\) values based on methods described by Dr. Pat Schloss and the use of lists with inline reporting based on Tristan Mahr’s post on lists for reporting. About a year ago, Garrick Aden-Buie began work on epoxy which is used for “extra-strength inline syntax.” Let’s give it a go…

Here we perform a one sample t-test and assign it to a variable. Here is automatically gets added to a list which can be accessed with the \(\$\) operand.

result <- t.test(CO2$conc, mu=550)

From this we get a \(p\)-value.

result$p.value
[1] 0.0006133941

Unfortunately, the result isn’t formatted very nicely.

In the past, following the Schloss method, I would have used the scales::pvalue() verb to format the value.

This would be written as: \(p\) = `r scales::pvalue(result$p.value)` to produce \(p\) = <0.001. However, the syntax to achieve this is a bit complicated. The epoxy library makes this easier.

An epoxy chunk written like this…

```{epoxy}
$p$ = {result$p.value}
```

will produce this…

\(p\) = 0.000613394053155454

But reformatting with epoxy, which relies on the same scales() package under the hood, does it very simply.

```{epoxy}
$p$ = {.pvalue result$p.value}
```

will produce this…

\(p\) = <0.001

Documentation has options for various inline transformers. For example, we might want to do something with money. For example we might write:

```{epoxy}
I want to find {.dollar 123456789} dollars.
```

this will produce…

I want find $123,456,789 dollars.

Citation

BibTeX citation:
@online{craig2024,
  author = {Craig, Nathan},
  title = {Inline {Reporting} {Redux}},
  date = {2024-03-12},
  url = {https://ncraig.netlify.app/posts/2024-03-12-inline-reporting-redux/index.html},
  langid = {en}
}
For attribution, please cite this work as:
Craig, Nathan. 2024. “Inline Reporting Redux.” March 12, 2024. https://ncraig.netlify.app/posts/2024-03-12-inline-reporting-redux/index.html.