Annotating text output on the fly….
Step 1. First, run whatever command that generates what you want to annotate and use capture_text to save it to a .png file.
capture_text(summary(lm(mpg ~ wt, mtcars)), "model_summary.png", width=2, height=1, units="in", res=300, pointsize=2)
Step 2. Next, use the tikzannotate to annotate the .png you just created.
Step 3. You’re done. There’s no step 3.
Code is available here: http://github.com/altaf-ali/rtikz
\usetikzlibrary{annotate}
\definecolor{darkgreen}{RGB}{0,128,0}
\begin{annotated_figure}{model_summary.png}
\annotate{1}{blue, fill=blue, opacity=0.05}{0.100, 0.62}{11cm}{1.1cm}{west}{blue}{east}
\annotate{2}{red, fill=red, opacity=0.05}{0.256, 0.35}{2.3cm}{2cm}{north}{red}{south}
\annotate{3}{red, fill=red, opacity=0.05}{0.371, 0.35}{2.8cm}{2cm}{north}{red}{south}
\annotate{4}{red, fill=red, opacity=0.05}{0.509, 0.35}{2.0cm}{2cm}{north}{red}{south}
\annotate{5}{red, fill=red, opacity=0.05}{0.610, 0.35}{3.3cm}{2cm}{north}{red}{south}
\annotate{6}{darkgreen, fill=darkgreen, opacity=0.05}{0.100, 0.125}{17cm}{0.5cm}{west}{darkgreen}{east}
\end{annotated_figure}
knitr::kable(tibble::tribble(
~Statistic, ~Description,
"Residuals", "difference between observed and predicted values",
"Estimate", "...",
"Std. error", "...",
"t-value", "...",
"p-value", "...",
"R-squared", "..."
), row.names = TRUE)
| Statistic | Description | |
|---|---|---|
| 1 | Residuals | difference between observed and predicted values |
| 2 | Estimate | … |
| 3 | Std. error | … |
| 4 | t-value | … |
| 5 | p-value | … |
| 6 | R-squared | … |